Support » Themes and Templates » How to place a google adsense banner in the header

Viewing 10 replies - 1 through 10 (of 10 total)
  • WPyogi

    (@wpyogi)

    Forum Moderator

    You’d need to modify the header.php file – but before doing that you’ll need to create a child theme so that your changes are not overwritten when the theme is updated.

    See: http://codex.wordpress.org/Child_Themes

    hanflow

    (@seonghoon52)

    hanflow

    (@seonghoon52)

    Yogi,

    I’ve created a child theme, by creating a new directory titled ‘blaskan-child’ and placing an identical copy of styles.css and functions.php in it.

    No what could I try?

    hanflow

    (@seonghoon52)

    In the new css.style file..it’s almost blank. it just has this:

    /*
    Theme Name:     blaskan child theme
    Description:    child theme
    Author:         HanFlow
    Template:       blaskan
    
    (optional values you can add: Theme URI, Author URI, Version)
    */
    
    @import url("../blaskan/style.css");
    WPyogi

    (@wpyogi)

    Forum Moderator

    Yes, it will be, but at the moment you don’t have a child theme active on your site. Once created, you need to activate it just like switching to any other new theme.

    WPyogi

    (@wpyogi)

    Forum Moderator

    Yes, that looks correct, try activating the child theme.

    hanflow

    (@seonghoon52)

    Its activated! =]

    WPyogi

    (@wpyogi)

    Forum Moderator

    Cool – so you want the ad on the left at the very top? or where?

    WPyogi

    (@wpyogi)

    Forum Moderator

    Assuming top left – make a new file header.php in your child theme with this code in it:

    <!DOCTYPE html>
    <!--[if IEMobile 7 ]><html id="blaskan" class="no-js iem7" <?php language_attributes(); ?>><![endif]-->
    <!--[if lt IE 7 ]><html id="blaskan" class="no-js ie6" <?php language_attributes(); ?>><![endif]-->
    <!--[if IE 7 ]><html id="blaskan" class="no-js ie7" <?php language_attributes(); ?>><![endif]-->
    <!--[if IE 8 ]><html id="blaskan" class="no-js ie8" <?php language_attributes(); ?>><![endif]-->
    <!--[if IE 9 ]><html id="blaskan" class="no-js ie9" <?php language_attributes(); ?>><![endif]-->
    <!--[if (gt IE 9)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html id="blaskan" class="no-js" <?php language_attributes(); ?>><!--<![endif]-->
    <head>
    	<meta charset="<?php bloginfo( 'charset' ); ?>">
    	<title><?php blaskan_head_title(); ?></title>
    	<?php wp_head(); ?>
    	<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    </head>
    <body <?php body_class(); ?>>
    <?php echo blaskan_top(); ?>
    <div id="site">
    	<div id="wrapper">
              <div id="ad">put my ad code here</div>
    		<header id="header" role="banner">
    		  <?php echo blaskan_header_structure(); ?>
    		</header>
    		<!-- / #header -->

    Then in your new child theme style.css file, add this:

    #ad {
       width: 728px;
       height: 90px;
       border: 2px solid red;
    }

    Obviously, change the border or size as you wish.

    hanflow

    (@seonghoon52)

    Yes, but there’s a problem. It’s impossible to fit a 728×90 ad with a decent sized logo image next to it, which is why I was asking how to enlarge the body width by 30~50px on my other post. I messed around yesterday and the ad and logo don’t fit right, they end up being stacked on top of each other.

    Thank you for always being so responsive Yogi.

    Update: Please check out the site now and see what I mean.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to place a google adsense banner in the header’ is closed to new replies.