Skip to content

Instantly share code, notes, and snippets.

@Jursdotme
Last active August 29, 2015 14:02
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 Jursdotme/c76ee353bcff0504f259 to your computer and use it in GitHub Desktop.
Save Jursdotme/c76ee353bcff0504f259 to your computer and use it in GitHub Desktop.
Wordpress Submenu
<?php
// use wp_list_pages to display Parent page and all child pages.
$ids = get_post_ancestors($page);
$parent = array_pop($ids);
if (empty($parent)) {
$parent = get_the_ID();
}
$args=array(
'child_of' => $parent
);
$pages = get_pages($args);
if ($pages) {
$pageids = array();
foreach ($pages as $page) {
$pageids[]= $page->ID;
}
$args=array(
'title_li' => '',
'include' => $parent . ',' . implode(",", $pageids),
'hierarchical' => '0',
'depth' => '-1',
'sort_column' => 'menu_order',
);
echo '<ul class="nav nav-pills varme nav-stacked">';
$thelist = wp_list_pages($args);
echo "</ul>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment