Title: AdSense To Header
Last modified: August 20, 2016

---

# AdSense To Header

 *  Resolved [Stergos](https://wordpress.org/support/users/stergos/)
 * (@stergos)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/)
 * Hi, i use twenty eleven theme actually a child theme. I try to add AdSense to
   Header (header.php) to the top right corner but i am not sure where i should 
   place the AdSense code to do that, any help appreciated thank you!

Viewing 15 replies - 1 through 15 (of 23 total)

1 [2](https://wordpress.org/support/topic/adsense-to-header/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/adsense-to-header/page/2/?output_format=md)

 *  [Ryan Yu](https://wordpress.org/support/users/geeksfolder/)
 * (@geeksfolder)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/#post-2366803)
 * Where are you trying the add the adsense, on the header or beside header?
 * Either way you will have to alter your header.php file to add the adsense code.
 *  Thread Starter [Stergos](https://wordpress.org/support/users/stergos/)
 * (@stergos)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/#post-2366876)
 * Hi and thanks for reply, i try to add a banner at the top right of the header,
   like this site: [http://statcounter.com/](http://statcounter.com/).
 * I know that i have to place the code to header.php but i am not sure where exactly
   and if i need to place any alternative codes with adSence like <right></right
   >…
 * Thanks for advance!
 *  [Ryan Yu](https://wordpress.org/support/users/geeksfolder/)
 * (@geeksfolder)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/#post-2366964)
 * There’s no adsense on the site you mentioned,
    but I guess you want to add the
   adsense like the yellow box from the screenshot (the ad size is 468 x 60). [http://postimage.org/image/tqiri7m95/](http://postimage.org/image/tqiri7m95/)
 * To do this, open header.php and on line 102, find the code below:
 *     ```
       <?php
       	// Has the text been hidden?
       	if ( 'blank' == get_header_textcolor() ) :
       ?>
       	<div class="only-search<?php if ( ! empty( $header_image ) ) : ?> with-image<?php endif; ?>">
       	<?php get_search_form(); ?>
       	</div>
       <?php
       	else :
       ?>
       	<?php get_search_form(); ?>
       <?php endif; ?>
       ```
   
 * Comment out the search function and add top-adsense div box.
    So it will look
   something like:
 *     ```
       <div id="top-adsense">
           <!-- adsense code goes here -->
       </div>
       <?php
       	// Has the text been hidden?
       	if ( 'blank' == get_header_textcolor() ) :
       ?>
       	<div class="only-search<?php if ( ! empty( $header_image ) ) : ?> with-image<?php endif; ?>">
       	<?php //get_search_form(); ?>
       	</div>
       <?php
       	else :
       ?>
       	<?php //get_search_form(); ?>
       <?php endif; ?>
       ```
   
 * Open style.css and add the css code:
 *     ```
       #top-adsense {
       	width:468px;
       	height:60px;
       	position:absolute;
       	right:3.6%;
       	top: 3.5em;
       }
       ```
   
 * Let me know if it works ok 🙂
 *  Thread Starter [Stergos](https://wordpress.org/support/users/stergos/)
 * (@stergos)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/#post-2366978)
 * Not really it was place the banner above of menu and below of header image, any
   other ideas?
 * [http://statcounter.com/](http://statcounter.com/)
    (when i open this site i 
   see a banner to the top-right corner on the header image)
 *  [Ryan Yu](https://wordpress.org/support/users/geeksfolder/)
 * (@geeksfolder)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/#post-2366980)
 * Sorry I cannot see any adsense from the site.
    Can you take a screenshot and 
   show me?
 *  Thread Starter [Stergos](https://wordpress.org/support/users/stergos/)
 * (@stergos)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/#post-2366987)
 * Oh i’m so sorry this is available only to users… Here how is like!
    [statcounter](http://i1014.photobucket.com/albums/af264/image231/statcounter.png)
 *  [Ryan Yu](https://wordpress.org/support/users/geeksfolder/)
 * (@geeksfolder)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/#post-2367008)
 * I see. To add the banner below the header graphic and above the menu,
    add this
   code uder the search form area.
 * Same as above, find this code from header.php;
 *     ```
       <?php
       	// Has the text been hidden?
       	if ( 'blank' == get_header_textcolor() ) :
       ?>
       	<div class="only-search<?php if ( ! empty( $header_image ) ) : ?> with-image<?php endif; ?>">
       	<?php get_search_form(); ?>
       	</div>
       <?php
       	else :
       ?>
       	<?php get_search_form(); ?>
       <?php endif; ?>
       ```
   
 * and add the “top-adsense” div below the code above.
    So it will look something
   like;
 *     ```
       <?php
       	// Has the text been hidden?
       	if ( 'blank' == get_header_textcolor() ) :
       ?>
       	<div class="only-search<?php if ( ! empty( $header_image ) ) : ?> with-image<?php endif; ?>">
       	<?php get_search_form(); ?>
       	</div>
       <?php
       	else :
       ?>
       	<?php get_search_form(); ?>
       <?php endif; ?>
       <div id="top-adsense">
       	<!-- Your Adsense goes here -->
       </div>
       ```
   
 * and add the css code to style.css;
 *     ```
       #top-adsense {
       	width:468px;
       	height:60px;
       	background:yellow;
       	margin:10px auto;
       }
       ```
   
 * Let me know how it went.
 *  Thread Starter [Stergos](https://wordpress.org/support/users/stergos/)
 * (@stergos)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/#post-2367029)
 * geeksfolder thanks for you reply, i did not try it yet cause i have problems 
   moving my site to another server but i will try it soon, thanks again!!!
 * p.s. i just try it for a second but is the same think.
 * I use [NomNom](http://zeaks.org/nomnom-twenty-eleven-child-theme/) child theme
   and it’s not have the above code to the header.php but i try to find the place
   it should be. Okay this is my header code:
 * _[large amount of code removed – please follow the [forum guidelines for posting code](http://codex.wordpress.org/Forum_Welcome#Posting_Code)]_
 *  Thread Starter [Stergos](https://wordpress.org/support/users/stergos/)
 * (@stergos)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/#post-2367039)
 * Anyone please???
 *  [Ryan Yu](https://wordpress.org/support/users/geeksfolder/)
 * (@geeksfolder)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/#post-2367049)
 * If you are using NomNom theme,
    add the div box right above the code below in
   header.php (line 128);
 *     ```
       <?php
       	// Has the text been hidden?
       	if ( 'blank' == get_header_textcolor() ) :
       ?>
       ```
   
 * and also add the css code from my previous comment to style.css
 *  Thread Starter [Stergos](https://wordpress.org/support/users/stergos/)
 * (@stergos)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/#post-2367052)
 * geeksfolder the complete code above is from the Header.php and as you can see
   the code you telling me “if ( ‘blank’ == get_header_textcolor() ) :” is not exist…
 *  [Ryan Yu](https://wordpress.org/support/users/geeksfolder/)
 * (@geeksfolder)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/#post-2367053)
 * You should see the code in the original NomNom theme.
    But ye it seems you have
   altered the header.php…
 * Within your code, add the div box right below;
 * `<?php endif; // end check for removed header image ?>`
 * Not 100% sure if it would work though as the code you have is different to what
   I have downloaded from NomNom site.
 * Let me know if it works ok.
 *  Thread Starter [Stergos](https://wordpress.org/support/users/stergos/)
 * (@stergos)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/#post-2367055)
 * Already try to add div below there, by doing this is create a space with the 
   ad on it between the header image and menu. Is looking really bad ^^
 *  Thread Starter [Stergos](https://wordpress.org/support/users/stergos/)
 * (@stergos)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/#post-2367069)
 * It’s must be some way to do this…. not only for advertising but for customizing
   too now is so empty!!!
 *  [zeaks](https://wordpress.org/support/users/zeaks/)
 * (@zeaks)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adsense-to-header/#post-2367071)
 * What Geeksfolder posted works, but the adsense should be placed inside the <div
   id=”nomnom-header”>, then use top: 0; and right: 0;

Viewing 15 replies - 1 through 15 (of 23 total)

1 [2](https://wordpress.org/support/topic/adsense-to-header/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/adsense-to-header/page/2/?output_format=md)

The topic ‘AdSense To Header’ is closed to new replies.

## Tags

 * [header](https://wordpress.org/support/topic-tag/header/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 23 replies
 * 7 participants
 * Last reply from: [aasbd](https://wordpress.org/support/users/aasbd/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/adsense-to-header/page/2/#post-2367141)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
