techxplore blog
26Jul

Adding Adsense Link Unit In Header Of WordPress Theme

Placing some Google Adsense ads on your blog could be an option. Earnings from single clicks are not really that big compared to writing a single blog post. Anyway, here’s a way to put Google Adsense on top of your blog header. The header file is header.php, the footer file is footer.php and the content file is index.php. The simplest of WordPress themes have the index.php including the header.php and the footer.php files. It would look like this:

<?php get_header(); ?>
<?php get_footer(); ?>

In between the header and the footer is the content. Customizing the header of the WordPress Theme and put a Google Adsense Link Unit is done by editing header.php file. It is very easy and I assure you that you’ll never use your acne cream on this. This is simple and straight forward. One can finish it in no time at all.

Just open header.php and

<div id=”header”>
<div id=”headerimg”>
<h1><a href=”<?php echo get_option(‘home’); ?>/”><?php bloginfo(‘name’); ?></a></h1>
<div class=”description”>
<?php bloginfo(‘description’); ?>
</div>
</div>
</div>

You could change the file by inserting after the headerimg div id into.

<div id=”header”>
<div id=”headerimg”>
<h1><a href=”<?php echo get_option(‘home’); ?>/”><?php bloginfo(‘name’); ?></a></h1>
<div class=”description”>
<?php bloginfo(‘description’); ?>
</div>
</div>
<div style=”position:relative; float:left; z-index:98; left: 5px; top: 15px;” >
<script type=”text/javascript”><!—
google_ad_client = “pub-6209093439227788”;
google_ad_width = 468;
google_ad_height = 15;
google_ad_format = “468x15_0ads_al”;
//2007-09-14: techxplore link unit top
google_ad_channel = “471178362”;
google_color_border = “F49E0F”;
google_color_bg = “AEF727”;
google_color_link = “0000FF”;
google_color_text = “000000”;
google_color_url = “008000”;
//—>
</script>
<script type=”text/javascript” src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script>
</div>
</div>

by inserting the Google Adsense Top Link Unit Javascript Code above you’ll get the listed header with a Adsense for Top Link.

This might be a simplistic way of showing how to put an Adsense Top Link on the WordPress Theme header.php file, but that’s how it’s done.

2 Responses to “Adding Adsense Link Unit In Header Of WordPress Theme”

  1. Vinayak Says:

    Do I need to add the code and close the div or was that code already there?
    I was going to set adsense on my Cricket Highlights Website but was scared by the innumerable number of plugins which I found online.Glad that I found your post,now again I dont need to fear rejection of being banned by Google because of using some plugins.

  2. vinayak Says:

    Now should I add the 1st code manually in my site or what.I cant see the above code in my site

Leave a Reply