I’m trying to get a different sidebar to load within child pages of a particular parent.

This is what I have so far:

register_sidebars(1, array(
'name' => 'Other Sidebar',
'id' => "other-sidebar",
'before_widget' => '<li class="widget">',
'after_widget' => '</li>',
'before_title' => '<span class="widgettitle">',
'after_title' => '</span>'
));

if ( $post->post_parent == '1164' ) {
dynamic_sidebar( 'other-sidebar' );
}

But I’m wondering if I need use a filter of some sort to replace the default sidebar that is being loaded instead? Not too sure if that’s correct or not.

Read more here: Replace sidebar for child pages without plugin


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: