Created
June 17, 2014 13:45
-
-
Save graylaurenm/f6c282ce5c6f38870ab2 to your computer and use it in GitHub Desktop.
Add Custom Widget Areas in Genesis with Examples http://oncecoupled.com/2014/01/24/adding-custom-widget-areas/
This file contains 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 # EXAMPLE TO REGISTER AND POSITION ANY NEW WIDGET AREAS | |
/** | |
* Created By: Lauren Gray Designs | |
* URL: http://oncecoupled.com | |
*/ | |
//* POSTS Register new widget area | |
lgd_register_sidebars(); | |
function lgd_register_sidebars() { | |
genesis_register_sidebar( array( | |
'id' => '[WIDGET_ID]', | |
'name' => __( '[WIDGET_NAME]', 'CHILD_THEME_NAME' ), | |
'description' => __( '[WIDGET_DESCRIPTION]', 'CHILD_THEME_NAME' ), | |
) ); | |
} | |
//* POSTS Postition new widget after posts | |
add_action( '[GENESIS_HOOK]', 'lgd_widget_after_post' ); | |
function lgd_widget_after_post() { | |
genesis_widget_area( '[WIDGET_ID]', array( | |
'before' => '<div class="widget-area">', | |
'after' => '</div>', | |
) ); | |
} | |
?> |
This file contains 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 # EXAMPLE TO REGISTER NEW WIDGET AREA AND PLACE BELOW PRIMARY SIDEBAR | |
/** | |
* Created By: Lauren Gray Designs | |
* URL: http://oncecoupled.com | |
*/ | |
//* POSTS Register new widget area | |
lgd_register_sidebars(); | |
function lgd_register_sidebars() { | |
genesis_register_sidebar( array( | |
'id' => 'lgd-psb-widget', | |
'name' => __( 'Primary Sidebar - Bottom', 'CHILD_THEME_NAME' ), | |
'description' => __( 'This widget area appears under your main sidebar.', 'CHILD_THEME_NAME' ), | |
) ); | |
} | |
//* POSTS Postition new widget after primary sidebar | |
add_action( 'genesis_after_sidebar_widget_area', 'lgd_sidebar_bottom', 9 ); | |
function lgd_sidebar_bottom() { | |
genesis_widget_area( 'lgd-psb-widget', array( | |
'before' => '<div class="lgd-psb-widget primary-sidebar-bottom widget-area">', | |
'after' => '</div>', | |
) ); | |
} | |
?> |
This file contains 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 # EXAMPLE TO REGISTER NEW WIDGET AREA AND PLACE BELOW EVERY POST | |
/** | |
* Created By: Lauren Gray Designs | |
* URL: http://oncecoupled.com | |
*/ | |
//* POSTS Register new widget area | |
lgd_register_sidebars(); | |
function lgd_register_sidebars() { | |
genesis_register_sidebar( array( | |
'id' => 'lgd-apc-widget', | |
'name' => __( 'After Post Content', 'CHILD_THEME_NAME' ), | |
'description' => __( 'This widget area appears after post content, to promote newsletter subscriptions.', 'CHILD_THEME_NAME' ), | |
) ); | |
} | |
//* POSTS Postition new widget after posts | |
add_action( 'genesis_entry_footer', 'lgd_widget_after_post' ); | |
function lgd_widget_after_post() { | |
if ( ! is_singular( 'post' ) ) | |
return; | |
genesis_widget_area( 'lgd-apc-widget', array( | |
'before' => '<div class="lgd-apc-widget after-post-content widget-area">', | |
'after' => '</div><div class="clear"></div>', | |
) ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment