WordPress.org

Ready to get started?Download WordPress

Forums

Center AdSense Above Header and Add to Child Theme (14 posts)

  1. adlawrence
    Member
    Posted 2 years ago #

    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
    }
  2. WPyogi
    Forum Moderator
    Posted 2 years ago #

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

    Don't use capital letters in CSS code.

  3. WPyogi
    Forum Moderator
    Posted 2 years ago #

  4. WPyogi
    Forum Moderator
    Posted 2 years ago #

    You might consider using a plug-in for AdSense:

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

  5. adlawrence
    Member
    Posted 2 years ago #

    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.

  6. WPyogi
    Forum Moderator
    Posted 2 years ago #

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

  7. adlawrence
    Member
    Posted 2 years ago #

    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.

  8. adlawrence
    Member
    Posted 2 years ago #

    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?

  9. WPyogi
    Forum Moderator
    Posted 2 years ago #

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

  10. adlawrence
    Member
    Posted 2 years ago #

    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.

  11. WPyogi
    Forum Moderator
    Posted 2 years ago #

    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.

  12. adlawrence
    Member
    Posted 2 years ago #

    I removed the img tags.

  13. WPyogi
    Forum Moderator
    Posted 2 years ago #

    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.

  14. adlawrence
    Member
    Posted 2 years ago #

    Thanks for your help, WPyogi.

Topic Closed

This topic has been closed to new replies.

About this Topic