July 4, 2014

Textual description of firstImageUrl

How To Add Adsense Code To Single Post Php Template Without div class="entry" Code

|

Single Php Post Template No div="entry" Code 


This is one of those common problems asked by many people out there. I was also having this problem when I used PR News Theme.

As I looked through the Internet, I found there are equally as many different and confusing answers to this issue.

I read through various forums and finally I found one which actually works.      

Most of the WordPress themes which you have used, it is very easy to paste Adsense code below the post title.

You just place the code after <?php post_class(); ?>.

But then there are WordPress themes, when you go to their single post.php, you see something like this:

add adsense to single post without div class entry

You tried pasting it after the first line, and it didn't work, right?

You CANNOT just paste the Adsense code right in this kind of single.php template.

Here is how to do it.

With this kind of theme, you will see content.php under Templates on the right side of your WordPress admin page.

You have to create another php template called post-content.php

How To Create Post-Content.php


1. Double click on the content.php to open it.

2. Copy out the code and paste it on your Notepad.

3. Save it as post-content.php

4. Now go to your host server (BlueHost, HostGator, ServerFreak, etc).

5. Double click on wp-content, then double click on themes.

6. Double click on the theme you are using.

7. Then go to the top and click Upload.

8. A new page will open. Click on Browse button.

9. Select the post-content file which you have saved earlier as mentioned in #2.

10. Once it has finished uploading. you should see it among the other files in the particular theme, as shown below.

how to create post-content.php

11. Now go back to your WordPress admin page. Reload the page by clicking on the curve arrow sign on the address bar. You should see post-content.php under Templates. See below:

create post-content.php tutorial
  
12. Next you have to replace the code in your single.php.

13. Look for this part of the code:

get_template_part('content',get_post_format());

Add post- to the word content.

14. It should look like this:

get_template_part('post-content',get_post_format());
   
15. Click Update File.

16. Now go and paste your Adsense code to the newly setup post-content.php

17. To have the code below the post title, look for this line of code:

<div class="post-content">

18. Paste Adsense code AFTER <div class="post-content">.

19. To centralize your Adsense code, just add <center> and </center> between your Adsense code.

20. Click  Update File button.

I hope this tutorial is helpful to you and don't forget to share this guide to others.