Posted By

zartgesotten on 08/13/10


Tagged

menu php wordpress sidebar code


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jamalmohamed


Wordpress 2nd Level Menu Subpages


 / Published in: PHP
 

This is what I wanted:\r\nI had a structure like this:\r\n-Artist\r\n --Peter Miller\r\n ---Pictures\r\n ---Press\r\n ---Videos\r\n\r\nand wanted to have the sub-sub-Menu when located on the \"Peter Miller\"-Page. \r\nSo that on \"Peter Miller\" you\'d have \"Pictures, Press and Videos\"-Menu and also on the sibling pages but not on Artists-Page!

  1. <?php
  2. global $wp_query;
  3. if( empty($wp_query->post->post_parent) )
  4. {
  5. $parent = $wp_query->post->ID;
  6. }
  7. else
  8. {
  9. $parent = $wp_query->post->post_parent;
  10. } ?>
  11.  
  12. <?php if(wp_list_pages("title_li=&child_of=$parent&echo=0" )): ?>
  13. <ul class="submenus">
  14. <?php wp_list_pages("title_li=&child_of=$parent" ); ?>
  15. </ul>
  16.  
  17. <?php endif; ?>

Report this snippet  

You need to login to post a comment.