patric-boehner
8/25/2016 - 6:24 AM

Add a widget area to all single pages in genesis

Add a widget area to all single pages in genesis

<?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>',
	) );

}
<?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>',
		) );
	}
}