Last active
October 4, 2016 08:07
-
-
Save phpbits/0c2e7850865738efb4ff89e6f5b9a120 to your computer and use it in GitHub Desktop.
Create Genesis Framework Widgetized Homepage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* CUSTOM SIDEBAR | |
| ========================================================================== */ | |
| add_action('init', 'hp_register_sidebar_widgets'); | |
| function hp_register_sidebar_widgets(){ | |
| register_sidebar(array( | |
| 'name' => __( 'Homepage Widgets', 'widget-options' ), | |
| 'id' => 'homepage-widgets', | |
| 'description' => __( 'Widgets in this area will be shown on homepage after header section.', 'widget-options' ), | |
| 'before_widget' => '<div id="%1$s" class="widget %2$s">', | |
| 'after_widget' => '</div>' | |
| )); | |
| } | |
| /* DISPLAY CUSTOM SIDEBAR BELOW HEADER SECTIOn | |
| ========================================================================== */ | |
| add_action( 'genesis_after_header', 'do_homepage_widgets', 99 ); | |
| function do_homepage_widgets(){ | |
| if( is_home() || is_front_page() ){?> | |
| <div class="hp-widgets-section"> | |
| <div class="wrap"> | |
| <?php | |
| if(!dynamic_sidebar('homepage-widgets')): | |
| endif; | |
| ?> | |
| </div> | |
| </div> | |
| <?php } | |
| } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment