02
Feb
2011

How to Show Google Adsense only on Homepage in WordPress

Posted in: WordPress Tips and Tricks 2 Comments

wordpress
In this tutorial, I will show you how to show Google Adsense Ads or any Ads to appear only on homepage.
Use below code for this:

<?php if(is_home() && $post==$posts[0] && !is_paged()) { ?>
     Google Adsense Code Here
<?php } ?>

Another method is:

<?php if (is_front_page()) : ?>
Google Adsense Code Here
<?php endif; ?>

In above code, just replace Google Adsense Code Here to your actual Adsense code. You can use any code that you want to appear only on homepage of WordPress.

browse premium wordpress themes

About the Author

Name: Ravi Shekhar
I love blogging and designing WordPress and Drupal themes.

2 Responses to How to Show Google Adsense only on Homepage in WordPress

  1. Karo says:

    Genius! Best solution on the web! Thanks a million; you don’t know how awesome this code is.

  2. Ian Albert says:

    works like a charm! thanks! :D

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>