Display A Google Ad Directly After the First Post

Written by on February 26, 2011 in WordPress Tutorials - 2 Comments

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.

About

Briley Kenney is a young freelance writer who enjoys all things electronic and techie related. Currently Briley writes for a plethora of professional websites including Productwiki, Uberoid, The Tech Labs, and of course WPMods. You can find more personal information on Briley's professional portfolio site here.

Post comment as twitter logo facebook logo
Sort: Newest | Oldest

great post thank you,
make it easier to implement

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?