• Resolved Stergos

    (@stergos)


    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)
  • 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

    (@stergos)

    Hi and thanks for reply, i try to add a banner at the top right of the header, like this site: https://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!

    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).
    https://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

    (@stergos)

    Not really it was place the banner above of menu and below of header image, any other ideas?

    https://statcounter.com/
    (when i open this site i see a banner to the top-right corner on the header image)

    Sorry I cannot see any adsense from the site.
    Can you take a screenshot and show me?

    Thread Starter Stergos

    (@stergos)

    Oh i’m so sorry this is available only to users… Here how is like!
    statcounter

    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

    (@stergos)

    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 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]

    Thread Starter Stergos

    (@stergos)

    Anyone please???

    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

    (@stergos)

    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…

    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

    (@stergos)

    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

    (@stergos)

    It’s must be some way to do this…. not only for advertising but for customizing too now is so empty!!!

    zeaks

    (@zeaks)

    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)
  • The topic ‘AdSense To Header’ is closed to new replies.