Code-snippit: submenu in WordPress

Deze code laat (buiten de loop) een submenu zien van een pagina met kinders in WordPress

<?php  
if($post->post_parent) {  
  $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&sort_column=menu_order");  
  $titlenamer = get_the_title($post->post_parent);  
} else {  
  $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&sort_column=menu_order");  
  $titlenamer = get_the_title($post->ID);  
}  
if ($children) { ?>
  <h2> <? echo $titlenamer ?> </h2>  
  <ul id="sidebar-menu">    
    <?php echo $children; ?>  
  </ul>
<?php } ?>

See it in action: Regelink.net

Bron: WordPress forum

About these ads

Published by

Rian Rietveld

Web developer @ RRWD web development | WordPress and Accessibility

2 thoughts on “Code-snippit: submenu in WordPress”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s