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.
Thank you for your article that nice easy to read. Your site has a lot of good topics contents, I would not fail to trace the address of your web site my friend(s) and visit often.
Hi there…Thanks for the post. I believe there are ways to convert my psd based templates to wordpress, but I do not have a clue…I am not a coder, but know web blogging. Is anyone familiar with the special software for psd publishing, if such exists?
What if I want to show a banner ad on a specific post page? Where should I add this code?
sorry but one question ….. where will i put this code?means in which file of the theme………. function.php……….. or stylesheet.php…… or another ?please answer i am new in this world
oh thanks no need to tell that i have done this
In the sidebar or footer or header files. You can use it where ever you want to use this code.
I was looking for a solution to show only in a front page a piece of code and this solutions worked exactly the way I was looking form, I really saved my day : )
thanks for the script, Where do i put it ????
Put it where ever you want to restrict the code to homepage.
Thanks..
that worked like a charm
this is very useful code and works nice tnx dude.also why do work adsense is nice one
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
@Scott..
Yes, There is a plugin called Why Do Work Adsense which will let you customize the adsense code placement. Try it.