» » WordPress: How To Add Google Adsense To Your First Post Only

WordPress: How To Add Google Adsense To Your First Post Only

posted in: WordPress | 0

Prevent your ad code from appearing after every single post and just show after 1st or 2nd post.

index.php

Before the line with the endwhile; add the following:

1
2
3
<!--?php if( is_home() &#038;& $wp_query--->current_post == 0 ) { ?&gt;
ADSENSE CODE
<!--?php } ?-->

If you want ad on your second post, change == 0 to == 1 and if you want ad on your third post, change == 0 to == 2

WordPress Rocks! If you can dream it, I can create it!
Like this article? Please click below to share it. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *