Code-snippit: submenu in WordPress

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

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; ?>  
<?php } ?>

See it in action:

Bron: WordPress forum


Author: Rian Rietveld

WordPress Engineer focussing on accessibility

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

Leave a Reply

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

You are commenting using your 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