My WordPress site - where in the editor to add AdSense code

I have AdSense code (728X90) I’d like to paste directly underneath the red banner at very top of [B]my index page here[/B]. However, when I log into my wp admin, do I do this in my CSS Style Sheet Editor or in another editor?

I don’t totally know your theme and how it is set up, but most likely you will you need to open up header.php located in your active themes folder.

Then look for the <header></header> section, then within that you will find code for your logo image, and an <hgroup> then the code for your nav. After the closing </hgroup> and before the nav code add

<div class="banner"></div>

paste your add code in there

<div class="banner">
add code goes here
</div>

Then add this to your stylesheet:

.banner{
  width:728px;
  height:90px;
  margin:0 auto;
  margin-top:20px;
}

Then if you only want it on your home page you will have to add some conditional code around the entire thing:

<?php if ( is_home(); ) { ?>
<div class="banner">
ad code goes here
</div>
<?php } ?>

If is_home(); doesn’t work, try [URL=“http://codex.wordpress.org/Function_Reference/is_front_page”]is_front_page(); instead.

Having said all that, your theme might offer another way to do this. :slight_smile:

Hope this is helpful. :slight_smile:

Hi RetroN: Great info. Yes, it looks like you’re very correct because after I personally researched how I am set up (have my own custom theme), I see this in my header.php :

Retro: I accessed my “header.php” and see the screenshot here. My theme is a custom theme so am ready to add my Google code. But I want to be certain, this is where, correct? And it ought to be visible across and throughout my entire site right? Let me know when you can and thanks…if anything else I need to be aware of, please give a holler
.

Add it right after the </hgroup>

</hgroup>

<div class="banner">
add code goes here
</div>

:slight_smile:

See this screenshot I just made…like this? I blocked out my advertiser id info but if this is good, I will add it and update the page. I want that banner ad to be visible in that spot throughout the site…i.e., if you click other pages, you still see that at top, correct?

Yes that looks like the right spot, but remember to also add the banner division and place your code inside of it:

<div class="banner">

replace this text with your code

</div>

and add the .css to your style.css file:

.banner{
  width:728px;
  height:90px;
  margin:0 auto;
  margin-top:20px;
}

:slight_smile:

Great…sorry for being so cautious, but this entire code:

<div class=“banner”>

<script async src=“//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<!-- cartoon-pictures –>
<ins class=“adsbygoogle”
style=“display:inline-block;width:728px;height:90px”
data-ad-client=“ca-pub-xxx”
data-ad-slot=“xxx”></ins>
<script>
(adsbygoogle = window.adsbygoogle || ).push({});
</script>

</div>

will go in spot where I pointed the red arrow…I will also add that extra code in my CSS stylesheet…let me know, I really appreciated your guidance! Just want to be sure . . .

Yes, right where you have the code in the screenshot, replace it with what is pasted above. :slight_smile:

It works! Thanks so much Retro. Verify by checking the various pages in drop down on far right of top menu. I like it. My big question is why it isn’t appearing on [B]index or my main page[/B]. Is it something I need to add extra in my style sheet? If Paul G is monitoring…I will soon delete that ad on left of page…I promise. Otherwise, this is appreciated alot!

Cool! :slight_smile:

I can’t say for sure why it isn’t appearing on the front page, but it must be that the home page is using something other than the header.php file (which seems odd) but you never know, or it could be some code in the header.php file.

What is the code above the fold in your last screenshot? :slight_smile:

Above the

<?php endif; ?>

at the top.

Hi Retro - for whatever “odd” reason, that banner ad is now visible on my index page (in my signature below) without my doing anything…cannot figure it out because for quite some time, nothing appeared there, only on all “inner” pages…late last evening I checked one last time…boom, there it was! Now as Paul mentions, am just going to get rid of that ad on upper left (in yellow widget) -very soon. My other question pertains to that menu bar above that upper left ad (Useful Links) and to the right of that (Welcome) - can those both be deleted in my APPEARANCE>EDITOR>(and then?)…not certain where I would navigate in my wp-admin to edit that. Am asking this since my theme was customized for me by someone else and want to now learn the rest on my own. Thanks!

Awesome!!!

Check under Appearance > Menus for your menu, but be careful and make sure you understand the menu before altering it. :slight_smile:

Retro: Greatly appreciated all your help on this (and patience!) - I had the IT specialist who assisted me in customizing my theme, to actually go in and do that latest edit. Your help has been phenomenal…and yes Paul…soon that ad on left will disappear. Btw Paul, I wonder if I can edit that ad to just show text links now that the wording in that menu bar is gone?

BACK AGAIN RetroNetro…sticking to this thread so I may also ask a question as I “experiment” with the 728X90 banner ad just below my logo…I am thinking of putting in a simple row of adsense 728X15 link unit in that spot now. So, if I delete the adsense code, do I also delete the <div class=“banner”> above the code and the </div></hgroup> below it? This is BEFORE I add the new adsense code for the link unit.