Skip to content

Instantly share code, notes, and snippets.

@dalethedeveloper
Created April 26, 2013 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dalethedeveloper/5469023 to your computer and use it in GitHub Desktop.
Save dalethedeveloper/5469023 to your computer and use it in GitHub Desktop.
WordPress Sidebar Example, pulling in one level of Child Pages for navigation. Mimics typical Sidebar Widget classes.
<?php
global $post;
$which_parent = empty($post->post_parent) ? get_the_ID() : $post->post_parent;
if( is_page() and get_children('post_status=publish&post_type=page&numberposts=1&post_parent='.$which_parent) ):
?>
<li id="widget-child-nav" class="widget">
<a href="<?php echo get_permalink($which_parent); ?>">
<h2 class="widgettitle"><?php echo get_the_title($which_parent); ?> Menu</h2>
</a>
<ul>
<?php wp_list_pages('title_li=&depth=1&child_of='.$which_parent); ?>
</ul>
</li>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment