How to add Adsense beneath blog post title

Community Forums Forums Design Tips and Tricks How to add Adsense beneath blog post title

This topic is: not resolved

Tagged: 

This topic contains 10 replies, has 4 voices, and was last updated by  raunekk 1 year, 10 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #9515

    fskhan619
    Participant
    Post count: 2

    How to add Adsense beneath blog post title? I’m using Focus Child theme.

    #9538

    AC
    Blocked
    Post count: 7712

    Install Genesis Simple Hooks – http://wordpress.org/extend/plugins/genesis-simple-hooks/ and then activate it.

    Look for the box that says – genesis_after_post_title

    Paste your code in there and save it.

    #9541

    buddy_boy8403
    Participant
    Post count: 132

    I did this for a client.  What I did was create a new sidebar area (Nick The Geek has a good tutorial on how to do this on his website).  You need to reference the appropriate genesis hook in the sidebar code – StudioPress has a hook reference to help you out with this.

    You can try this and see if this is what you need.  Just add the code to your child theme’s functions.php file and the styling to your child theme’s style.css file:

    /** Start Add Sidebar After Content */
    // First we have to register the new sidebar
    genesis_register_sidebar( array(
    'id' => 'after-content-ad',
    'name' => 'Bottom Of Page Ad Area',
    'description' => 'This is a sidebar that goes after the content.',
    ) );
    // Next we have to display the sidebar
    add_action( 'genesis_after_content_sidebar_wrap', 'child_after_content_ad_sidebar' );
    /** Loads a new sidebar after the content */
    function child_after_content_ad_sidebar() {
    // Now we add the conditional to show this everywhere except the home page by putting an ! in front of is_home()
    // For more info about conditional tags, see: http://designsbynickthegeek.com/tutorials/conditional-page-content
    if (is_single() ) {
    echo '';
    dynamic_sidebar( 'after-content-ad' );
    echo '';
    }
    }
    // Finally we need to style the sidebar in the child theme's style.css file
    /** End Add Sidebar After Content */

    Now for the CSS styling

    /* Ad Sidebar
    ------------------------------------------------------------ */
    .after-content-ad {
    clear: both;
    margin: 0 auto;
    width: 728px;
    }

    #9542

    AC
    Blocked
    Post count: 7712

    I think the code you pasted broke.

    #9544

    buddy_boy8403
    Participant
    Post count: 132

    I think the code you pasted broke.

    I fixed it – thanks.

    #9560

    fskhan619
    Participant
    Post count: 2

    Thanks both of you ..! Genesis Simple Hooks works best but I wan’t the ad to appear on the post page only, not on the homepage. Can you show me how can I do that?

    #9571

    buddy_boy8403
    Participant
    Post count: 132

    @fskhan619 – The code I gave to modify your functions.php file does this.  Thats what the following conditional does in that snippet:

    if (is_single() )

    Just copy/paste that to the bottom of your functions.php file, update the styling in your style.css file and modify the styling to suite your needs.

    Once you create the new widget area, just go to your Appearance > Widgets page, drag a text widget in there and paste the adsense code. After that, you should be good to go.

    #9613

    AC
    Blocked
    Post count: 7712

    @fskhan619 – here is the code you need. I hope the code posts.
    <?php if(is_single()) { ?>
    <center>
    ***Paste AdSense Code Here***
    </center>
    <?php } ?>

    #9708

    fskhan619
    Participant
    Post count: 2

    @buddy_boy8403

    It works perfectly and thanks a lot for replying and helping!  But the widget lets you add content at the bottom of the page beneath the content and I want to add adsense (large rec) beneath the Post Titles.

    #9720

    buddy_boy8403
    Participant
    Post count: 132

    Then try adding this to your functions.php file.  Don’t remove the one you just put in there from your functions.php file in case later on down the road you wanted to use it.  Just don’t drag any widgets to that sidebar:

    /** Start Add Sidebar Before Post */
    // First we have to register the new sidebar
    genesis_register_sidebar( array(
    'id' => 'before-posts-sidebar',
    'name' => 'Before Posts Ad Area',
    'description' => 'This is a sidebar that goes before the post content.',
    ) );
    // Next we have to display the sidebar
    add_action( 'genesis_before_post_content', 'child_before_posts_sidebar' );
    /** Loads a new sidebar before the posts in the #content */
    function child_before_posts_sidebar() {
    // Now we add the conditional to show this everywhere except the home page by putting an ! in front of is_home()
    // For more info about conditional tags, see: http://designsbynickthegeek.com/tutorials/conditional-page-content
    if (is_single() ) {
    echo '
    ';
    dynamic_sidebar( 'before-posts-sidebar' );
    echo '
    ';
    }
    }
    // Finally we need to style the sidebar in the child theme's style.css file
    /** End Add Sidebar Before Post */

    #9728

    raunekk
    Participant
    Post count: 40

    Use “quick adsense” plugin. It’s quite helpful with a lot of features.

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

You must be logged in to reply to this topic.