Created
April 26, 2013 17:46
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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