Support » Fixing WordPress » Center AdSense Above Header and Add to Child Theme

  • I updated my WordPress site to 3.4.2 and have now created a child theme since I lost several modifications. Here’s the site: http://reddoorreview.com

    I’m trying to:
    1. Ad my AdSense ad at the very top of my site back,
    2. Center it horizontally,
    3. And make sure that it doesn’t disappear when I update WordPress again.

    I’ve gotten it to appear again, but not through the child theme. How do I do that (since the child theme is CSS and I’m looking to add details to the header.php file)?

    Plus, I got it to center before, but it isn’t centering horizontally any more. Suggestions?

    On header.php:

    <img class="displayed">
    <script type="text/javascript"><!--
    google_ad_client = "ca-pub-5427562956145395";
    /* Skyad */
    google_ad_slot = "0192440898";
    google_ad_width = 728;
    google_ad_height = 90;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    </img>

    On the child theme:

    IMG.displayed {
        display: block;
        margin-left: auto;
        margin-right: auto
    }

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

    (@wpyogi)

    Forum Moderator

    You need to put the modified header.php file in the child theme.

    Don’t use capital letters in CSS code.

    WPyogi

    (@wpyogi)

    Forum Moderator

    WPyogi

    (@wpyogi)

    Forum Moderator

    You might consider using a plug-in for AdSense:

    http://wordpress.org/extend/plugins/search.php?q=adsense

    OK, so I put a modified header.php file in the child theme folder?

    Thanks for the validation errors. I figured there would be problems with the image tag and what not. What’s the best way to get the ad to center horizontally?

    I’m not a huge fan of plugins because several slowed down my page load time. By deactivating some plugins, I SERIOUSLY improved the time it took for pages to load and also stopped crashing my server.

    WPyogi

    (@wpyogi)

    Forum Moderator

    The code you added is in the wrong place — it has to be inside the body tags, and it looks like it is not.

    Thanks, WPyogi. It was just before the closing head tag. I thought it was supposed to be there, but I could be mixing it up with the analytics code. I think I am.

    I put it in just after the opening body tag.

    And now that I’ve reloaded the page, that’s not where I wanted it. I want it above the header, where the open space is between the browser bars and the header image.

    It’ll be OK there if I can close the space between the header image and the browser. Anyone know how to do that?

    WPyogi

    (@wpyogi)

    Forum Moderator

    Did you add the image tags or were they part of the adsense code?

    I added them. I was trying to make this suggestion work, but haven’t found a way yet. I also tried to make it into a div, but didn’t get that to work either.

    WPyogi

    (@wpyogi)

    Forum Moderator

    Remove them and just leave the code right inside the body tags. Let me look at it like that.

    BTW, image tags would never be what you should use…divs should work, but let’s first see whether they are needed at all.

    I removed the img tags.

    WPyogi

    (@wpyogi)

    Forum Moderator

    I have to get off and do some other stuff right now, but hopefully someone else can pick this up. I’m also really not familiar with adding AdSense code directly, so not the best advisor on this either. You might also go back to trying some plug-ins and see if you can find one that does it without slowing down your site.

    Thanks for your help, WPyogi.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Center AdSense Above Header and Add to Child Theme’ is closed to new replies.