Show only 2nd level of navigation depending on active navigation

Try this – I’ve not implemented it fully, but I have tested it and it seems to work. Place it in your functions.php and call <?php list_child_pages(); ?> in your template or use the shortcode [childpages] in your editor.

<?php
// List Child pages of a parent. 
function list_child_pages() {

global $post;

if ( is_page() && $post->post_parent )
    $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=" . $post->post_parent . "&echo=0' );
else
    $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=" . $post->ID . "&echo=0' );

if ( $childpages ) { ?>
    <menu>
        <ul class="side-nav">
            <?php echo $string = $childpages; ?>
        </ul>
    </menu>
<?php   
}

return $string;

}
// Add Shortcode for additional support, not just in the theme template
add_shortcode('childpages', 'list_child_pages');

?>

Leave a Comment