Howto : Add Ads After First Post on your Wordpress Homepage

Google limits us to display 3 ad units and 1 link unit on any given page. In Wordpress, if we would like to add adsense on the homepage, we would be limited to header, sidebar and the footer. If we add ads at the end of an article, the loop repeats the ad at least 10 times. You don’t want that to happen, isn’t it? Ideally, it would be perfect to add an ad right after the first post which could pose an unprecedented challenge. Here is a small snippet which could do the trick for you without much sweat.

1. Open your FTP application and browse to the theme files. Locate either index.php or home.php depending on the theme and open them.
2. Find this code in the file : <?php endwhile; ?> or one of its variants such as <?php endwhile; else: ?>.
3. Just before the endwhile code, insert this code:
<?php if(!$show_ads){ ?>
YOUR ADSENSE/AD GOES HERE
<?php $show_ads = 1; } ?>

4. Save the file and upload.
5. That’s it!

Piece of cake isn’t it. If you have any further clarifications, let me know…

Related posts:

  1. Howto : Decrypt Wordpress Footer
  2. Troubleshooting the Wordpress Blank Page
  3. Wordpress Customized Feature Post
  4. Advantages of Open Source Content Management Systems like Wordpress
  5. 11 Unix Tricks

Filed Under: BloggingWordpress

Tags: , ,

About the Author

Abhinav Kaiser is a certified project manager (PMP) and an expert in IT service management. He has been writing on several blogs for over 6 years and has been a source of inspiration for many budding bloggers. He recently started a blog, Abhinav PMP and his latest baby in the works needs special mention - Success Mantras. Click here if you need to get in touch.

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.