Site logo

Archived topic

Sidebar for children of a particular parent page

3 replies · Started by George on August 28, 2021

Viewing posts 1–4 of 4

I need help with some code. How can I modify this code to return the right sidebar for children of a particular parent page?

Right now, I am using:

add_filter( 'generate_sidebar_layout', function( $layout ) {
    if ( is_page() && 11017715 == $post->post_parent ) {
        return 'right-sidebar';
    }

    return $layout;
 } );

but it doesn't work.

Yesss. It works.

add_filter( 'generate_sidebar_layout', function( $layout ) {
    global $post;

    if ( is_page() && $post->post_parent == '11017715' ) {
        return 'right-sidebar';
    }

    return $layout;
 } );

Thanks, Leo!

No problem :)

This archived topic is closed to new replies.