Skip to content

Instantly share code, notes, and snippets.

@afsalrahim
Last active September 19, 2018 05:37
Show Gist options
  • Save afsalrahim/59e2cb9646fc7c95656c to your computer and use it in GitHub Desktop.
Save afsalrahim/59e2cb9646fc7c95656c to your computer and use it in GitHub Desktop.
Show Custom Sidebar for Specific Page for Genesis Theme
<?php
/**
* Show Custom Sidebar for Specific Page
*
* @author Afsal Rahim
* @link http://digitcodes.com/show-custom-sidebar-for-specific-pages-in-wordpress-using-genesis/
*/
// Registering new sidebar
genesis_register_sidebar( array(
'id' => 'contact-sidebar',
'name' => __( 'Contact Page Sidebar'),
'description' => __( 'This is the careers page sidebar section.' ),
) );
add_action( 'get_header', 'child_sidebar_for_page' );
function child_sidebar_for_page() {
if ( is_page('contact') ) {
remove_action( 'genesis_after_content', 'genesis_get_sidebar' );
add_action( 'genesis_after_content', 'get_sidebar_for_page' );
}
}
function get_sidebar_for_page() {
echo '<div id="sidebar">';
genesis_before_sidebar_widget_area();
dynamic_sidebar( 'contact-sidebar' );
genesis_after_sidebar_widget_area();
echo '</div>';
}
@Tierra-de-Osos-Mk
Copy link

fhgfh### ### awdawd###

awd `` @ #

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment