Ashley Cameron Design

Ashley Cameron Design

Shop the Creative Design Market

Goodnight

Show 2nd & 3rd Level Navigation Together

SnippetsWordPress

About a 1 minute read

"Not until we are lost do we begin to understand ourselves."

Henry David Thoreau


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 } ?>