The New Blogger Adsense widget has an option called “Show Ads Between Posts“.
So, how could we display or show Adsense ads between posts in WordPress theme? No worry. There are only two steps to go:
In this WordPress theme, these are the changes made to display a banner ads format after the 3rd post and a big square ads format at the last post of WalkerNews.net index page:


So, how could we display or show Adsense ads between posts in WordPress theme? No worry. There are only two steps to go:
- Edit the index.php (one of the WordPress theme file)
- Add this PHP snippet right after the
the_contentfunction call<?php $postcnt++; if (($postcnt % 2) == 0){ echo 'Your Adsense Code Here'; }; ?>
You can change the modulus (e.g $postcnt % 2 == 1 or $postcnt % 3 == 1) as you like.
In this WordPress theme, these are the changes made to display a banner ads format after the 3rd post and a big square ads format at the last post of WalkerNews.net index page:
<?php
$postcnt++;
if ($postcnt == 3){
echo 'Banner format Adsense code';
} elseif ($postcnt == 7){
echo 'Big square format Adsense code';
};
?>


Custom Search



2013 •
Really nice mode, thanks for sharing!
nice post dude, i was looking for something exactly like that. I’ve got very little experience with PHP, although i am a good coder in C++ and Java , so changing that code to my need is gonne be easier now.
Thanks though.
Thank you for your kindness.
[...] WordPress automatically removes any punctuation marks from the post title for permalink, it can’t [...]
Thanks for this! Was just wondering how to do ads between posts.
Hi,
Thanks a lot you have done a really good job…
Does it work with an image instead of adsense? I want to place a comic strip instead of an ad. Could you explain how to call the image?
Best regards
Erico
Just replace the echo line with image code.
How can I do this displaying ads between comments?
No one knows how to display ads between comments?