webworthydesign
4/7/2015 - 5:17 PM

Pull in current page menu as list of pages in a <ul>

Pull in current page menu as list of pages in a

<?php
if( $post->post_parent ) {
  $args = array(
  	'title_li' => '', 
  	'child_of' => $post->post_parent, 
  	'echo' => 0, 
  	'sort_column'  => 'menu_order',
  );
  $children = wp_list_pages( $args );
  $titlenamer = get_the_title($post->post_parent);
} else {
  $args = array(
  	'title_li' => '', 
  	'child_of' => $post->ID, 
  	'echo' => 0, 
  	'sort_column'  => 'menu_order',
  );
  $children = wp_list_pages( $args );
  $titlenamer = get_the_title($post->ID);
} ?>
	
<?php if ($children) : ?>
  <h3><?php echo $titlenamer; ?></h3>
  <ul class="sidemenu">
  	<?php echo $children; ?>
  </ul>
<?php endif; ?>