Wordpress display list of subpages and siblings if there are any


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



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. <div id="submenu">
  14. <ul>
  15. <?php wp_list_pages("title_li=&child_of=$parent" ); ?>
  16. </ul>
  17. </div>
  18. <?php endif; ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.