Blogging Tips
Browsing all articles in Making Money
4

I just wanted to post this quick tips article as I am sure it will be helpful to other webmasters. If you are looking for a way to put adsense ads after the first paragraph of each entry in your wordpress blog OR if you want to place an adsense ad block after second or third paragraph of each entry, then here is what you can do.

The following need some simple code editing in wordpress template file (single.php)

1. Find the php file – single.php in your wordpress blog themes folder.
2. search for the code: <?php the_content(); ?>
3. Replace the above code with the following:
<?php
$paragraphAfter= 1; //display after the first paragraph
$content = apply_filters('the_content', get_the_content());
$content = explode("</p>", $content);
for ($i = 0; $i <count($content); $i++) {
if ($i == $paragraphAfter) { ?>

<div>

Your add code here

</div>
<?php
}
echo $content[$i] . "</p>";
} ?>

You can now place your adsense ad code into the place where it is written “Your ad code here”. You can also change the number of paragraph after which you would like your adsense ad to appear. This can be done by replacing the number in the code $paragraphAfter= 1 with the paragraph number after which you want the ad to be seen. I sure hope this is helpful.