• I have created several sidebar widget areas in functions.php. I then put this code in sidebar.php to display certain sidebars on certain pages:

    <div id="secondary" class="widget-area" role="complementary">
    	<?php
    	if ( is_page( 6 ) || $post->post_parent == '6') { dynamic_sidebar( 'sidebar-2' );
    	} elseif ( is_page( 8 ) || $post->post_parent == '8') { dynamic_sidebar( 'sidebar-3' );
    	} else { dynamic_sidebar( 'sidebar-1' );
    	} ?>
    </div><!-- #secondary -->

    My problem is that this works only on the main nav page and its immediate sub-nav pages but on sub-sub-nav pages the sidebar reverts to the default sidebar. What conditional tag can I use to target the ancestor of any sub-page no matter how many levels deep?

    Thanks!

  • The topic ‘How to display a custom sidebar on sub-sub-pages’ is closed to new replies.