web statistics

How To : Place Adsense After The First Post

Posted on July 18th, 2008 under Tips,Tricks and Hacks, Tutorials, WordPress
ADVERTISMENTS
Share |

With many way monetize a blog, we need to place our ads in different positions, one place is the right after the first post on the homepage.To place a banner or an adsense ad right after the first post follow these steps.

  • Open your index.php or home.php based on your WP Theme
  • Look for these lines of code

    <?php if (have_posts())

      • Before that add these lines of code

        <?php $count = 1; ?>

    • Next find, this line

    <?php the_content() ?>

  • After that line, add these lines of code

    <?php if ($count == 1) : ?>
    Adsense/Banner Ad Code Goes Here
    <?php endif; $count++; ?>

    You can also change the count value in Step 3 and 5, to 2 if you want to have the ad after the 2nd post.

  • Written by Avinash

    Browse Tech Yard for the latest & interesting web applications, Freewares, Wordpress Tips, Firefox Hacks and Addons, Mobile Phones, Windows - Linux - MAC OS Tricks.

    Stumble Digg Technorati Reddit Delicious


    Related Posts

    4 Responses to “ How To : Place Adsense After The First Post ”

    1. Rockstar Sid says:

      Good one.. I am still tryin to learn all the wp loops in wordpress.. :-|

    2. Nirmal says:

      I had implemented this when I used my previous theme.

    3. Venkat says:

      @RockStar Sid : This is something I learnt recently and wanted to share with you all.

      @Nirmal: Thanks for the comment nirmal, I hope you release your old theme it was really a nice theme.

    4. Siddharth says:

      nice trick ;)
      I now use OIO publsiher



    Leave a Reply

    Subscribe to TECH YARD:

    RSS

    Grab the RSS feed for Free Updates!


    subscribe

    Get blog updates sent directly to your inbox by entering your email address above.