Last active
August 26, 2016 04:59
-
-
Save patric-boehner/a0405fa4b7b29b7051b8ce345779315b to your computer and use it in GitHub Desktop.
Add a widget area to all single pages in genesis
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 | |
| //* Do NOT include the opening php tag shown above. Copy the code shown below. | |
| ///* Register Page Widget | |
| genesis_register_sidebar( array( | |
| 'id' => 'page-content-widget', | |
| 'name' => __( 'Page Content Widget', 'themename' ), | |
| 'description'=> __( 'This widget area shows within single page content area only.', 'themename' ), | |
| ) ); | |
| //* Add Widget Area to all Pages | |
| /* | |
| * Change the action hook to adjust where the widget area shows on the page | |
| * for more hooks see https://my.studiopress.com/docs/hook-reference/ | |
| * Additional, adjust the conditional statment to control which pages | |
| * the widget shows on. In this example, it shows on all pages. | |
| */ | |
| add_action( 'genesis_entry_content', 'pb_add_page_widget' ); | |
| function pb_add_page_widget() { | |
| if ( is_page() ) { | |
| genesis_widget_area ( 'page-content-widget', array( | |
| 'before' => '<div class="page-widget"><div class="wrap">', | |
| 'after' => '</div></div>', | |
| ) ); | |
| } | |
| } |
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 | |
| //* Do NOT include the opening php tag shown above. Copy the code shown below. | |
| //* Add Widget Area to all Pages | |
| /* | |
| * Alteritivly ddd the action to the page.php template | |
| * file and remove the conditional statment | |
| * | |
| * You will still need to register the widget area (lines 6-11 in the example above) in your functions.php file | |
| */ | |
| add_action( 'genesis_entry_content', 'pb_add_page_widget' ); | |
| function pb_add_page_widget() { | |
| genesis_widget_area ( 'page-content-widget', array( | |
| 'before' => '<div class="page-widget"><div class="wrap">', | |
| 'after' => '</div></div>', | |
| ) ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment