Wordpress 2nd Level Menu Subpages


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

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!


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.