• 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

Add Feature Image before Content

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 › General Discussion › Add Feature Image before Content

This topic is: not resolved

Tagged: Add Widget, feature box, hook, register widget

  • This topic has 6 replies, 2 voices, and was last updated 8 years, 11 months ago by jshinault.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • July 26, 2016 at 1:54 pm #190239
    jshinault
    Member

    Hi. I've been trying to add a feature box before my content on my homepage. I know I need to add a widget, but directions around here are very vague for me (since I'm not an expert in code). I know I need to register a new widget using the following code:

    //* Register after post widget area
    genesis_register_sidebar( array(
    	'id'            => 'after-post',
    	'name'          => __( 'After Post', 'themename' ),
    	'description'   => __( 'This is a widget area that can be placed after the post', 'themename' ),
    ) );

    But I don't know how to make it work for my website... Then I also know I need to use genesis_before_content hook, but again, I'm not sure where to place it.

    Could someone please help me out?

    http://www.joannashinault.com
    July 26, 2016 at 7:48 pm #190256
    Genesis Developer
    Member

    Try this code. Add it in your functions.php file.

    //* Register after post widget area
    genesis_register_sidebar( array(
    	'id'            => 'after-header',
    	'name'          => __( 'After Header', 'themename' ),
    	'description'   => __( 'This is a widget area that can be placed after the site header', 'themename' ),
    ) );
    
    add_action( 'genesis_after_header', 'themename_after_header', 20);
    function themename_after_header() {
       if( ! is_home() )
         return;
    
       if( is_active_sidebar( 'after-header' ) ):
       genesis_widget_area( 'after-header', array(
    		'before' => '<div class="after-header widget-area clearfix" id="after-header"><div class="wrap">',
    		'after'  => '</div></div>',
    	) );
      endif;
    }

    Explaining:

    1. Creating the new widget area
    2. Using the "genesis_after_header" hook and adding the new widget area after the "site-header" markup
    3. Returning early If user is not visiting the home page. is_home() function will return true if you are on home page.

     if( ! is_home() )
         return;

    4. If you activate the "After Header" widget area, then it will show the widget area after header. is_active_sidebar() is checking that a sidebar is active or not.
    5. Echoing the widget area by genesis_widget_area() function which is taking 2 parameters. One is widget ID as a string and another one is HTML markup as an array.

    Hope it will help you.


    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    July 26, 2016 at 8:51 pm #190260
    jshinault
    Member

    Thanks for the quick reply! Alright, I added the code from above, but how do I know if it worked or not? I don't see it in my widgets area... Am I missing something? Thanks again!

    July 26, 2016 at 9:07 pm #190262
    jshinault
    Member

    Also, I do want the widget to go above content and not below header since I want my feature image below the navigation bar. But I think I know how to replace the code to work with that.

    July 26, 2016 at 9:15 pm #190264
    Genesis Developer
    Member

    You are wanting the widget area above the every post content?

    If you did not add the widget in new widget area from your dashboard then it will not appear on your home page.


    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    July 27, 2016 at 12:54 pm #190313
    jshinault
    Member

    I want the widget below the navigation bar and above the first post on my homepage only.

    I do not see a new widget area on my dashboard...

    July 29, 2016 at 10:00 am #190446
    jshinault
    Member

    Any ideas? I really need this set in place on my site as soon as possible....

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘General Discussion’ 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