Display A Google Ad Directly After the First Post

in WordPress Tutorials

Display A Google Ad Directly After the First PostThere’s no point in discussing the semantics of advertising here, because it’s highly likely if you’re using a WordPress enabled blog or website you already have various advertising schemes running. In this tutorial we will not discuss basic use of Google AdSense code either, but if you would like further information on integrating Google AdSense ads into your WordPress blog please visit our related tutorial.

Display A Google Ad Directly After the First PostAdvertising can sometimes break up the visual aesthetics of a WordPress theme or ruin the layout, which means users are often stuck finding alternative ways to display ad banners and listings. One of the coolest ad display ideas involves placing advertisements (in this case Google AdSense adds) directly after the first blog post. This method helps keep the overall layout and theme clean and simple, while also displaying the advertisement right at the top of the page. This also keeps the ad highly accessible, exactly how Google wants it to be.

The Code to input Google Ads after the first post is quite simple. Open your theme “header.php” file by using either a standard text editor, admin web editing tool or the integrated WordPress appearance editor.

After doing so find the following line:

<?php endwhile; ?>

And add the code segment above/before the located code:

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

Obviously you must input your individualized Google Adsense code where it says “Insert AdSense Code Here”.

After that is all done you can save your “header.php” file and go check out your new blog advertisements! Congratulations your Google AdSense ads will now display ONLY before the first blog post on your page.

Comments (2)

  • Comment by Twicat.com

    great post thank you,
    make it easier to implement

  • Comment by Qairy

    this what i’m looking for..thanks buddy. By the way, how you put ads and related post side by side? can you tell me?