Posted By

zartgesotten on 06/27/09


Tagged

menu pages wordpress subpages


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

tmbrenneke
lilumi
irishsk


Wordpress display list of subpages and siblings if there are any


 / Published in: PHP
 

  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
Posted By: philipmjones on March 12, 2010

Perfect. Does just what it says on the tin.

I've used this in conjunction with the PHP Code widget to add 'In this section' to the sidebar

You need to login to post a comment.