Skip to content

Instantly share code, notes, and snippets.

@dannyconnolly
Last active December 29, 2015 12:49
Show Gist options
  • Save dannyconnolly/7673502 to your computer and use it in GitHub Desktop.
Save dannyconnolly/7673502 to your computer and use it in GitHub Desktop.
Child Menu for Wordpress
<?php
global $wp_query;
if( empty($wp_query->post->post_parent) ) {
$parent = $wp_query->post->ID;
} else {
$parent = array_reverse(get_post_ancestors($post->ID));
$parent = $parent[0];
}
if(wp_list_pages("title_li=&child_of=$parent&echo=0" )) {
?>
<ul class="sub-nav">
<?php
wp_list_pages("title_li=&child_of=$parent&echo=1" );
?>
</ul>
<?php
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment