Say "Hello!"

  • This field is for validation purposes and should be left unchanged.

Show 2nd & 3rd Level Navigation Together


1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php global $wp_query;
     $post = $wp_query->post;
     $ancestors = get_post_ancestors($post);
     if( empty($post->post_parent)) {
          $parent = $post->ID;
     } else {
          $parent = end($ancestors);
     }
     if(wp_list_pages("title_li=&child_of=$parent&echo=0")) { ?>
     
     <ul>
          <?php wp_list_pages("title_li=&child_of=$parent&depth=0"); ?>
     </ul>
<?php } ?>

Back to Snippets Follow me on GitHub

Ashley Cameron logo
Blog