Paste this PHP code at the end of your child themes functions.php file.
You’ll find a new widget which displays before the content on single posts and pages.
The code has been tested on the Twenty Eleven default theme for WordPress as well as the Genesis 2.0 Sample child theme.
Add Widget Before Single Posts & Pages In Genesis
Its preferable to use one of the code snippets on this page when using child themes built on the Genesis theme framework which are using the old XHTML markup and loop hooks.
Here’s an example of what works in themes running Genesis 2.0 with the new HTML 5 loop hooks & markup:
//* Register widget areas
genesis_register_sidebar( array(
'id' => 'before-content',
'name' => __( 'Before Content', '$text_domain' ),
'description' => __( 'Before Content widget On Single Posts & Pages Only', '$text_domain' ),
) );
add_action( 'genesis_entry_content', 'add_widget_before_content', 5 );
function add_widget_before_content() {
if( is_singular(array('post', 'page')) && is_active_sidebar('before-content') ) {
genesis_widget_area( 'before-content', array(
'before' => '<div class="before-content" class="widget-area">',
'after' => '</div>',
) );
}}
Style your widget using the .before-content class in your child themes style sheet.
Add New Widget Before Loop On Home Page Of Woo Theme
Paste this code in the custom code section of the Canvas themes functions.php file or your child themes functions file:
Need to change position?
Here’s a list of all Woo Hooks you can use in any theme.
Positioning Priority
Simply change the 3rd parameter in the action for positioning priority if needed.
Leave a Reply
You must be logged in to post a comment.