Support » Themes and Templates » Adsense into Header

  • Resolved samsnb



    I am trying to put adsense (horizontal banner) into the top right of my header.

    The theme I am using is Andyblue. There is already a search bar there, I would like to replace this with adsense.

    I am tried a number of different variations of my limited code knowledge and can’t get any of them to work. Any help would be greatly appreciated.

    The header code is as follows:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    <html xmlns="" xml:lang="en">
    <?php if ( is_home() ) : ?><title><?php bloginfo('name'); ?></title><meta name="keywords" content="italiasw, italia sw,, recensioni, web2, web 2, apps, applicativi, software, windows, windows xp, windows vista, vista, ict, recensioni ict, recensioni software, news, news high tech, blog italia, blog software, italia software, sw, blog informatica, news informatica, articoli informatica, recensioni web 2.0" /><meta name="description" content="<?php bloginfo('description'); ?>" />
    <?php endif ;?><?php if ( is_single()) { ?><title><?php the_title(); ?> » <?php bloginfo('name'); ?></title><?php } ?>
    <?php if ( is_search()) { ?><title>Search Result</title><?php } ?><?php if ( is_archive()) { ?><title><?php single_cat_title(); ?> » <?php bloginfo('name'); ?></title><?php } ?>
    <?php if ( is_page()) { ?><title><?php the_title(); ?> » <?php bloginfo('name'); ?></title><?php } ?><?php if ( is_404()) { ?><title>Error 404, Page not Found » <?php bloginfo('name'); ?></title><?php } ?>
    	<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    	<meta http-equiv="Content-Language" content="en-us" />
    	<meta http-equiv="imagetoolbar" content="no" />
    	<meta name="MSSmartTagsPreventParsing" content="true" />
    	<meta name="description" content="" />
    	<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
    	<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
    	<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
        <script src="" type="text/javascript"></script>
        <script src="<?php bloginfo('template_directory'); ?>/js/calculations2.js" type="text/javascript"></script>
    	<?php wp_head(); ?>
    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-33789199-1']);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    	<div id="header">
    	<h1><a></a><a>/"><?php bloginfo('name'); ?></a></h1>
    	<h2><?php bloginfo('description'); ?></h2>
    				<?php include (TEMPLATEPATH . '/searchform.php'); ?></div>
    <div <script type="text/javascript"><!--
    google_ad_client = "ca-pub-1236697108641913";
    /* THOC Header */
    google_ad_slot = "2441790312";
    google_ad_width = 468;
    google_ad_height = 60;
    <script type="text/javascript"

    Thanks for your help.


Viewing 12 replies - 1 through 12 (of 12 total)
  • to get rid of the searchbar, remove this:

    <?php include (TEMPLATEPATH . '/searchform.php'); ?>

    and repair this line:

    <div <script type="text/javascript"><!--


    <div> <script type="text/javascript"><!--

    there might be other problems with the formatting – to illustrate what is going wrong, please post a link to your site.

    Hi Alchymyth

    Thanks for replying.

    All good so far.

    The site is Take Home Pay Calculator.




    I have managed to remove the search bar but I am unable to change it to adsense.

    Can anyone assist please?



    If you have removed that search part now your code appear as follows

    <h2><?php bloginfo('description'); ?></h2>

    Just put your adsense code between </h2> and </div>

    That’s all.

    Hi Udaraaka

    Thanks for your reply.

    If I change that code it appears as follows Take Home Pay Calculator

    As opposed to within the blue header in the top right.

    Thanks for your help so far.


    Ok, first put the following code between </h2> and </div> instead of adsense code

    <div style="height:60px; width:100%; background-color:#467AA7"><div style="height:60px; width:500px; float:right;">

    Then put the adsense code between float:right;”> and </div></div>

    Remember you have to adjust height of both divs(60px) acourding to adsense ad height and width of the second inner div(500px) to fit with adsense ad width

    Let me know if there are any problems

    Thanks very much for that.

    It is working now within the header, is it possible to move it to the top now as oppose to the bottom of the header? Take Home Pay Calculator

    It is already so much better than before.



    What do you mean by move it to the top? you mean right side of the
    Take Home Pay Calculator
    Calculate your take home pay in seconds


    Yes, same position in on the right but just up level with the title.

    Thanks for your help.


    replace the current content between <div id=”header”> and your adsense code with the following code

    <div style="height:60px; background-color:#467AA7; float:left"><h1><a></a><a href="">Take Home Pay Calculator</a></h1>
    	<h2>Calculate your take home pay in seconds.</h2></div>
    <div style="height:100px; width:100%; background-color:#467AA7"><div style="height:60px; width:500px; float:right;">

    That is absolutely perfect.

    Thank you very much for your help.

    You are welcome.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Adsense into Header’ is closed to new replies.