How to Display / Show Ad Code only on Homepage of Wordpress Blog

You can control ad placements of your wordpress blog by different ways. One of them is showing Ads only on the home page. This can be done in two ways. One by the use of a code and other by using a simple plug-in. By using this you can show or display ads only on the homepage and block ads in the internal pages.

The first method is by using PHP code. This code lets you show ads or any content only on the homepage. All you have to do is add in your advertisement code in the following way update your theme to notice the changes.

<?php if ( is_home() ) { ?>

Code you want to show on your homepage

<?php } ?>

The second method involves a wordpress plug-in. It is called as Whydowork Adsense. After you download and install the plug-in, you will be presented with lot of options. Select the ad code and make it to show only on home page and you are done.

In these ways, you can show ads only on the homepage easily. You can use these codes not just for the advertisements but also for any Java script or other code. The purpose of this tip is to show any element only on the homepage of your wordpress blog. 


Loading
Tagged as: , , , , ,

3 Responses to “How to Display / Show Ad Code only on Homepage of Wordpress Blog”

  1. tips says:

    this is very useful code and works nice tnx dude.also why do work adsense is nice one

  2. Scott says:

    Hi Prasanth,

    Thanks for this helpful shortcode!

    I have another question (or two) if that’s ok. See, I’m creating a site using WP and I’m using “Pages” for the content pages so, whatever Adsense plugin I use I can’t seem to find out how to NOT have Adsense on certain pages like “About Us”, “Contact Us” etc. I only want Adsense on CERTAIN pages, not all of them.

    I don’t know PHP but I think I can manage to use your little bit of code to show Ads on the homepage, but what about other pages of content? Is there a simple solution?

    For example, is there a bit of code (maybe an if statement?) where I can add this code to my Page.php page but use &exclude= to exclude a certain number of IDs such as About, Contact, etc.?

    Thanks

    Scott

Leave a Reply

Get PCs Place Updates

Enter your email address:

PCs Place on Facebook

Search PCs Place