Display Custom Sidebar For Specific Page & Child Pages
// Display the 'my_custom_sidebar' for the page with ID of 2 and all children of this page
add_filter( 'wpex_get_sidebar', function( $sidebar ) {
if ( is_page() && ( is_page( '2' ) || '2' == wp_get_post_parent_id( get_the_ID() ) ) ) {
$sidebar = 'my_custom_sidebar';
}
return $sidebar;
} );
All PHP snippets should be added via child theme's functions.php file or via a plugin (we recommend Code Snippets)