Placing adsense in single posts only?

Community Forums Forums Design Tips and Tricks Placing adsense in single posts only?

This topic is: not resolved

This topic contains 8 replies, has 3 voices, and was last updated by  braddalton 10 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #44276

    guitario
    Participant
    Post count: 10

    Is there a simple way to place a 728×90 adsense banner between my header image and my post headers in single posts only?

    Using my previous theme I simply added the code to the ‘single.php’ folder but my Balance child theme doesn’t have this.

    So I’m assuming the code must go in the ‘functions.php folder instead but can someone shed some light into where exactly and what code snippet I would need to make this work? (I don’t understand php so please make it easy to understand)

    Thanks

    Jamie

    http://www.psycholocrazy.com/
    #44277

    braddalton
    Participant
    Post count: 9344

    Hi Jamie

    You can do this several ways:

    1. using CSS code
    2. using PHP code
    3. creating a new widget area with conditional tag

    3. Please copy this code from the view raw link and paste it at the end of your child themes functions.php file using a text editor like Notepad++.

    Code not displaying? Grab it on Github.

    You can change the hook position if needed.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #44278

    guitario
    Participant
    Post count: 10

    Hey Brad that worked great. One thing though, now that I have placed my banner ad there, there is a large white space between the ad and the header image/top menu.

    I will leave it there for you to have a look. Do you know how to reduce this, and to also leave a little white space between the bottom of the ad and the top of the post?

    Thanks

    Jamie

    #44279

    guitario
    Participant
    Post count: 10

    Wait, scrap the first part of that. It’s because I have a lot of white space in the image header… I think…

    #44282

    braddalton
    Participant
    Post count: 9344

    Line 260 of your child themes style.css file is where you can reduce the height of your header.
    [css]
    .header-image #title-area,
    .header-image #title,
    .header-image #title a {
    display: block;
    float: left;
    height: 135px;
    overflow: hidden;
    padding: 0;
    text-indent: -9999px;
    width: 350px;
    }
    [/css]
    Also on line 213
    [css]
    #header {
    margin: 0 auto;
    min-height: 135px;
    overflow: hidden;
    width: 960px;
    }
    [/css]
    You may also need to reduce the height in your child themes functions.php file:
    [php]
    /** Add support for custom header */
    add_theme_support( ‘genesis-custom-header’, array( ‘width’ => 960, ‘height’ => 135 ) );
    [/php]

    Another solution is to use a smaller banner and use a different hook like genesis_before_post_title or genesis_after_post_title


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #44283

    guitario
    Participant
    Post count: 10

    Thanks Brad that worked a treat!

    One last thing while you’re here… How can I create a bit more white stuff after the banner? It seems very squashed against the top of my post where the date is and the heading on my sidebar.

    You’ve been a great help

    Jamie

    #44286

    braddalton
    Participant
    Post count: 9344

    You can add some padding to the new widget area http://www.w3schools.com/css/css_padding.asp
    [css]
    .before-content {
    padding-bottom: 24px;
    }
    [/css]

    I couldn’t see the Adsense banner on single posts so cannot inspect the element using Firebug.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #69631

    hobbygirl66
    Participant
    Post count: 21

    How could you change this to include pages as well?
    Thanks!
    Lisa

    #69650

    braddalton
    Participant
    Post count: 9344

    Sure thing:

    Change the HTML 5 Loop hook position if needed.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.