• 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

Code confusion – Registering and displaying a new widget area

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 › Code confusion – Registering and displaying a new widget area

This topic is: not resolved

Tagged: widgets

  • This topic has 0 replies, 1 voice, and was last updated 2 years, 11 months ago by mohitb.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • August 22, 2019 at 12:07 am #493091
    mohitb
    Participant

    Hi,

    I was referring to a tutorial on how to register and display a widget area in a custom front page. While I understand the process of registering a widget area using genesis_register_widget_area ($args), was a little confused about the code (shown at the bottom of this post) used to display the widget area in front_page.php.

    If I modify the code below to just use the genesis_after_header hook, it seems to work exactly the same way.

    So is there something different going on when I use the genesis_meta hook to call the custom function my_homepage_setup and then use the genesis_after_header hook within the called function?

    add_action( 'genesis_meta', 'my_homepage_setup' );
    /**
     * Add widget support for homepage.
     *
     */
    function my_homepage_setup() {
    
    	if ( is_active_sidebar( 'front-page-1' ) )  {
    
    		 //* Add front page 1 widget
    		add_action( 'genesis_after_header', 'display_front_page_1_widget' );
    
    	}
    }
    
    // Add markup to display front page widgets.
    function display_front_page_1_widget() {
    
    	genesis_widget_area( 'front-page-1', array(
    		'before' => '<div class="front-page-1-widget"><div class="wrap">',
    		'after'  => '</div></div>',
    	) );
    
    }
  • Author
    Posts
Viewing 1 post (of 1 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

© 2022 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