Wordpress: 3rd Level Navigation, Show 2nd & 3rd Level Navigation Together


/ Published in: PHP
Save to your folder(s)

Yes this works, needs css ...


Copy this code and paste it in your HTML
  1. <?php global $wp_query;
  2. $post = $wp_query->post;
  3. $ancestors = get_post_ancestors($post);
  4. if( empty($post->post_parent)) {
  5. $parent = $post->ID;
  6. } else {
  7. $parent = end($ancestors);
  8. }
  9. if(wp_list_pages("title_li=&child_of=$parent&echo=0")) { ?>
  10.  
  11. <ul>
  12. <?php wp_list_pages("title_li=&child_of=$parent&depth=0"); ?>
  13. </ul>
  14. <?php } ?>
  15.  
  16.  
  17.  
  18.  
  19.  
  20. .children {display: none}
  21.  
  22. .current_page_item ul.children,
  23. .current_page_ancestor ul.children,
  24. .current_page_parent ul.children {display: block}

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.