Wordpress hierarchical sidebar nav


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

Wordpress hierarchical sidebar nav using wp_list_pages


Copy this code and paste it in your HTML
  1. <?php
  2. if($post->post_parent) {
  3. $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&sort_column=menu_order&exclude=88,93,91");
  4. $titlenamer = get_the_title($post->post_parent);
  5. }
  6.  
  7. else {
  8. $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&sort_column=menu_order&exclude=88,93,91");
  9. $titlenamer = get_the_title($post->ID);
  10. }
  11. if ($children) { ?>
  12.  
  13. <ul class="sidebar_nav">
  14. <?php echo $children; ?>
  15. </ul>
  16.  
  17. <?php } ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.