Help Me Add Adsense Under Header

Discussion in 'WordPress' started by Zion521, Jul 28, 2011.

  1. #1
    Hello guys,

    I'm having a bit of difficulty adding an adsense link under the logo of my wordpress site. I know it must be an easy fix for someone on here, and I was wondering if anyone can help me.

    I know that every theme is different. I would imagine that the solution would be found in the header.php file. I've tried entering my google snippet code in the header.php, but I guess i'm not entering it in the correct place. Sorry if this question seems a bit basic, but i'm not really good with html.

    Here is the header.php of the theme that i'm using:

    <?php
    global $options;
    foreach ($options as $value) {
    if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
    }
    ?>
    <!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    <head>
    <meta charset="<?php bloginfo( 'charset' ); ?>" />
    <title><?php wp_title(); ?> <?php bloginfo( 'name' ); ?></title>
    <link rel="profile" href="http://gmpg.org/xfn/11" />

    <!-- feeds & pingback -->
    <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
    <link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" />
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />

    <!-- main stylesheet, favicon, -->
    <link rel="icon" type="image/png" href="<?php echo $xs_favicon; ?>" />
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" />
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url');?>/css/<?php echo $xs_color_scheme ?>.css" media="screen" />

    <?php include (TEMPLATEPATH . '/fonts/'. $xs_google_font .'.php'); ?>
    <?php echo stripslashes($xs_custom_font); ?>

    <!-- wp head -->
    <?php wp_head(); ?>

    <!-- main js -->
    <script type="text/javascript" src="<?php bloginfo('template_url');?>/js/superfish.js"></script>

    <?php if ($xs_disable_slider == "true") { ?>
    <?php } else { ?>
    <!-- homepage slider -->
    <script type="text/javascript" src="<?php bloginfo('template_url');?>/js/jquery.nivo.slider.pack.js"></script>
    <script type="text/javascript">
    $(window).load(function() {
    $('#slider').nivoSlider({
    effect:'<?php echo $xs_slider_animation ?>',
    slices: <?php echo $xs_slider_slices ?>,
    animSpeed: <?php echo $xs_slider_speed ?>,
    directionNavHide: true,
    pauseTime: <?php echo $xs_slider_pause ?>,
    controlNav: false
    });
    });
    </script>
    <?php } ?>

    <!-- superfish menu -->
    <script type="text/javascript">
    $(document).ready(function() {
    $('ul.sf-menu').superfish({
    delay: 100,
    animation: {opacity:'show',height:'show'},
    speed: 'normal',
    autoArrows: true,
    dropShadows: true
    });
    });
    </script>

    <?php
    //get and show google analytics code
    echo stripslashes($xs_ga_code); ?>


    </head>
    <body>
    <div id="xs-wrap">
    <div id="xs-header">
    <div id="xs-header-logo">
    <?php if ($xs_enable_custom_logo== "true") { ?>
    <a href="<?php bloginfo( 'url' ) ?>" title="<?php bloginfo( 'name' ) ?>" rel="home"><img src="<?php echo $xs_custom_logo ?>" alt="<?php bloginfo( 'name' ) ?>" /></a>
    <?php } else { ?>
    <?php if (is_front_page()) {?>
    <h1><a href="<?php bloginfo( 'url' ) ?>/" title="<?php bloginfo( 'name' ) ?>" rel="home"><?php bloginfo( 'name' ) ?></a></h1>
    <?php } else { ?>
    <h2><a href="<?php bloginfo( 'url' ) ?>/" title="<?php bloginfo( 'name' ) ?>" rel="home"><?php bloginfo( 'name' ) ?></a></h2>
    <?php } ?>
    <p id="xs-header-description">
    <?php bloginfo( 'description' ) ?>
    </p>
    <?php } ?>
    <?php if ($xs_top_ad != '') { ?>
    <div id="xs-top-ad">
    <?php echo stripslashes($xs_top_ad); ?>
    </div><!-- /top-ad -->
    <?php } else { ?>
    <?php } ?>
    </div><!-- /xs-header-logo -->
    </div><!-- /xs-header -->
    <div id="xs-primary-menu">
    <?php
    if ( function_exists('wp_nav_menu') ) {
    wp_nav_menu( array(
    'theme_location' => 'primary',
    'sort_column' => 'menu_order',
    'menu_class' => 'sf-menu'
    ));
    }
    ?>
    <div class="clear"></div>
    <?php if ($xs_disable_seach_bar == "true") { ?>
    <?php } else { ?>
    <?php include (TEMPLATEPATH . '/searchform.php'); ?>
    <?php } ?>
    </div><!-- /xs-primary-menu -->
    <?php if ($xs_disable_breadcrumbs == "true") { ?>
    <?php } else { ?>
    <?php get_breadcrumbs(); ?>
    <?php } ?>
    <div id="xs-container">
    <div id="xs-main">
    <?php if ($xs_disable_slider == "true") { ?>
    <?php } elseif (is_front_page()) {?>
    <?php include (TEMPLATEPATH . '/nivoslider.php'); ?>
    <?php } else { ?>
    <?php } ?>

    Thank you so much for taking the time to read this
     
    Zion521, Jul 28, 2011 IP
  2. Zion521

    Zion521 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Anyone? I really need the help
     
    Zion521, Jul 28, 2011 IP
  3. wwwestwebs

    wwwestwebs Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Put the adsense code after this....

    <?php } ?>
    <p id="xs-header-description">
    <?php bloginfo( 'description' ) ?>
    </p>
    <?php } ?>

    -- code here --

    ...so the line immediately after the adsense code is this one...

    <?php if ($xs_top_ad != '') { ?>

    Your ads should appear below your site's description if it works.
     
    wwwestwebs, Jul 28, 2011 IP
  4. wwwestwebs

    wwwestwebs Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If that does not look good, try this....

    </div><!-- /xs-header-logo -->
    </div><!-- /xs-header -->

    ...Put your code here...
    --- the following lines should be as follows --

    <div id="xs-primary-menu">
    <?php

    This puts the ads immediately before the menu

    If you want it after the breadcrumbs, put the code here....

    <?php if ($xs_disable_breadcrumbs == "true") { ?>
    <?php } else { ?>
    <?php get_breadcrumbs(); ?>
    <?php } ?>

    -- put adsense code here - the following lines should appear after the code --

    <div id="xs-container">
    <div id="xs-main">
     
    wwwestwebs, Jul 28, 2011 IP
  5. Zion521

    Zion521 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you for your response, wwwestwebs!

    I've put in the code exactly as you've told me, and it still doesn't show up. The name of the theme is XS Wordpress Theme 1.01 by AJ Clarke, if that helps

    Once again, thanks for taking the time to help me

    I just saw your 2nd reply - i'll try it now!
     
    Zion521, Jul 28, 2011 IP
  6. wwwestwebs

    wwwestwebs Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Glad to help. Clear your browser's cache or force refresh - how you do that depends on your browser and platform (windows/mac/linux).

    After you clear your cache, reload the page and selet view source - check that the adsense code is roughly where you put it.

    If you see the adsense code in View Source, then Google is not yet serving ads - all you can do is wait for an hour, or two - they will eventually start serving ads.
     
    wwwestwebs, Jul 28, 2011 IP
  7. wwwestwebs

    wwwestwebs Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    If this does not end up working, there are some very good adsense plugins available - you just enter your publisher ID in some of them and they do the rest. But it depends on your theme too - you may not be able to place ads wherever you want using a plugin.
     
    wwwestwebs, Jul 28, 2011 IP
  8. Zion521

    Zion521 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I feel terrible. I've tried placing the code in all the places, it doesn't look like it's appearing at all...
    The specific area that I am trying to place the adsense links are normally populated by the Wordpress Menus. I want to place the links over this area. It seems as if this area is protected somehow?

    Also, if it helps, the area that i'm trying to populate is near the same location as the search bar.

    I'm so sorry to keep bothering. It's just that I believe this area is a great location for an adsense link unit.

    A plugin is not really going to help me in this case, due to the nature of the theme. I've done some minor modifications to wordpress themes before, but I just can't seem to figure this one out.

    The adsense bar (when not serving) is usually just a blank rectangle - but it's just not showing up when I place it in the code...

    I can't thank you enough for trying to help :)
     
    Last edited: Jul 28, 2011
    Zion521, Jul 28, 2011 IP
  9. wwwestwebs

    wwwestwebs Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Just chill -- reload the page and selet view source - check that the adsense code is roughly where you put it.

    If you see the adsense code in View Source, then Google is not yet serving ads - all you can do is wait for an hour, or two - they will eventually start serving ads.
     
    wwwestwebs, Jul 28, 2011 IP
  10. Zion521

    Zion521 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Still open to any suggestions. It seems that the adsense code doesn't even show up in the source code. (view source)
     
    Zion521, Jul 28, 2011 IP
  11. Zion521

    Zion521 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Bump - Good morning everyone
     
    Zion521, Jul 29, 2011 IP
  12. wwwestwebs

    wwwestwebs Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    There's a chance you could be editing the wrong php file since the adsense code is not showing up in the page's source for me too.
     
    wwwestwebs, Jul 29, 2011 IP