Tuesday, September 14, 2010

TutZone- Tutorials, Design news and Inspiration

TutZone- Tutorials, Design news and Inspiration

Link to TutZone

Display Ads in WordPress Only After First Post

Posted: 14 Sep 2010 04:49 AM PDT


If you ever tried to insert a piece of code or advertisement code in WordPress loop, you must have realized it would have shown after every post. With this simple hack you can show your ad code, whether it be Google Adsense or any other code, to show only after first post.

Procedure:

Note: Do take backup of your theme before you try this.

01. In your WordPress Admin panel go to Appearance => Editor.
editor

02. Then choose header.php file from right hand side and add search for this code:

<?php endwhile; ?>


And add below code (replaced with your ad code) immediately before above code:

<?php if(!$show_ads){ ?>
Insert Code Here
<?php $show_ads = 1; } ?>


03. Replace Insert Code Here with your ad code. This concludes this simple and useful tutorial. Hope you like it.

No comments:

Post a Comment