I wanted to know how could i display only the children of a nav menu. ive tried a couple of things like :

if($post->post_type == "page"){
            $postid = $post->ID;
            print_r( get_pages(array("child_of" => $postid)) );
        }   

But all i get an empty array.

so what i want is something like this: http://www.isic.org/student-card/the-isic-student-card.html

link|improve this question
feedback

2 Answers

Here you have the solution

 <ul>
  <?php
     $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
     $subpages = ($post->post_parent) ? wp_list_pages('title_li=&child_of='.$post->post_parent.'&echo=0') : wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0') ; 
          if ($children) { ?>
              <li><?php echo $children; ?></li>
          <?php } else { ?>
              <?php echo $subpages; ?>
  <?php } ?>
  <?php wp_reset_query() ?>
 </ul>

I used it to make a menu where the case was something like:

Parent Page: Service A Child: Overview, Features, Service Plan, FAQs, Quotes

And there were different services and each parent has their own child, take a look http://bit.ly/su4GGS

:)!

link|improve this answer
feedback

This really depends on how the menu is setup, but based on the code in your snippet you are using get_pages() so I assume its setup with pages.

Then you are better off using wp_list_pages() and to get the sub pages you would do something like this.

wp_list_pages('&child_of='.$post->ID.'&echo=0');

This will give you a list of items that are children of the current post/page id which it seems you are trying to do.

Here is a good tutorial that will probably help best. It sounds pretty much what you are trying to do, but I am not sure exactly as your question is a little vague.

http://www.svennerberg.com/2009/02/creating-a-submenu-in-wordpress/

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.