• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Need help with putting Adsense Ads above the post title and below the header…

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Need help with putting Adsense Ads above the post title and below the header…

This topic is: not resolved

Tagged: above post title, adsense, before entry title

  • This topic has 7 replies, 2 voices, and was last updated 9 years, 9 months ago by naturalsoldier.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • March 6, 2016 at 10:12 pm #180784
    naturalsoldier
    Member

    Hi,

    I'm trying to insert Adsense Ads above the main content (above post title and below header)
    on some of the main pages which include:

    Home Page
    Category Pages
    Single Post Pages

    Again I only want this ad to show up once on each page (at the top below the
    header and above the first post title), and I only want it to show up in
    the main content column.

    Please see a screenshot of the site that I am modeling mine after and
    notice the arrow pointing to the ad placement that I'm trying to
    replicate....

    http://snag.gy/n7JtI.jpg

    I think I have successfully accomplished this but need some feedback to
    make sure it checks out or if there is a better way.

    Below is the code that I have used with the plugin "Simple Hooks" to make
    this happen:

    (Note... I have placed this code in the genesis_before_entry hook)

    <?php
    global $wp_query;
    if( ($wp_query->current_post == 0) && is_home() ) {
    ?>
    <div class="codeblocktop">Sponsored Links
    [My Adsense Code Here}
    </div>
    <?php
    }
    ?>

    <?php
    if(is_single() ) {
    ?>
    <div class="codeblocktop">Sponsored Links
    [My Adsense Code Here}
    </div>
    <?php
    }
    ?>

    <?php
    global $wp_query;
    if( ($wp_query->current_post == 0) && is_archive() ) {
    ?>
    <div class="codeblocktop">Sponsored Links
    [My Adsense Code Here}
    </div>
    <?php
    }
    ?>

    This code has accomplished what I wanted it to, but I have some concerns that I would really appreciate help with...

    1.) Is the code correct and will it mess anything up?

    2.) Is there a cleaner piece of code that will accomplish the same thing?

    3.) Will my changes will get erased with updates?

    4.) Is the code placed in the correct hook location (genesis_before_entry)?

    5.) Is there a better way to accomplish what I'm trying to do?

    Like I said... it's working exactly how I want it to but just want to double check with folks who actually know what they're doing and make sure that I didn't mess anything up!

    Please forgive me as I am new to WordPress and learning as I go. I would
    appreciate any help you can give me. Thanks!

    P.S. My Child Theme: eleven40

    http://snag.gy/n7JtI.jpg
    March 7, 2016 at 8:40 am #180802
    Brad Dalton
    Participant

    Link to the site please


    Tutorials for StudioPress Themes.

    March 7, 2016 at 3:31 pm #180824
    naturalsoldier
    Member

    Oops... sorry about that!

    My site is at http://weluvdogs.com/

    I would appreciate any help you can give.

    Thanks!

    March 7, 2016 at 8:04 pm #180864
    naturalsoldier
    Member

    Is there anybody in here that can help?

    March 8, 2016 at 9:54 am #180910
    Brad Dalton
    Participant

    I would use the

    genesis_entry_header

    hook or an earlier hook with the

    is_singular('post'))
     conditional tag
    
    And add a new widget area there.

    Tutorials for StudioPress Themes.

    March 8, 2016 at 3:19 pm #180939
    naturalsoldier
    Member

    Thank you Brad. Can you please clarify what you mean in your response? Not sure I quite understand what you're saying to do. Sorry just new to all of this so want to make sure that I completely understand what you are saying here.

    Also, is there a cleaner piece of code that I should use?

    Thanks again!

    March 8, 2016 at 5:17 pm #180955
    Brad Dalton
    Participant

    Read this please http://my.studiopress.com/tutorials/register-widget-area/


    Tutorials for StudioPress Themes.

    March 9, 2016 at 12:58 am #180978
    naturalsoldier
    Member

    Thank you Brad but I've read that tutorial and re-read it about 10 times and I still can't figure it out lol.

    Here's what I've done so far...

    I placed the following code to register the new widget in my eleven40 functions.php file (note jerod is my name and what I've used to make the name unique so I can recognize it easily):

    //* Register jerod before post title widget area
    genesis_register_sidebar( array(
    'id' => 'jerod-before-post-title',
    'name' => __( 'Jerod Before Post Title', 'eleven40' ),
    'description' => __( 'This is a widget area that can be placed before the post title', 'eleven40' ),
    ) );

    The next part in the tutorial is where I get lost... How do I write the next part of the code in the tutorial and where do I place it? Sorry for being so dense on this... again learning as I go.

  • Author
    Posts
Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble