treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Wordpress main navigation and child

  • Hello, this is my first post and I must say well done to Chris Coyier this is a brilliant website. I use it a lot as I'm fairly new to using wordpress in terms of it's existance, the videos have been amazing to refer to it times of need - thanks!

    Anyway, is there a way of displaying only the child Navigation pages of a parent sections of pages on a separate part of a web page, for instance you have main parent page menu items along the top of a webpage and then display only the subpages of the parent along the bottom, this would mean that depending on the parent selected - the child menu item would be different along the bottom, hope this makes sense?
  • The codex is always the best place to start http://codex.wordpress.org/Template_Tags/wp_list_pages#List_subpages_even_if_on_a_subpage

    Just put this in your template where ever you want the list.
    		<?php
    if($post->post_parent)
    $children = wp_list_pages(\"title_li=&child_of=\".$post->post_parent.\"&echo=0\");
    else
    $children = wp_list_pages(\"title_li=&child_of=\".$post->ID.\"&echo=0\");
    if ($children) { ?>
    <ul>
    <?php echo $children; ?>
    </ul>
    <?php } ?>
  • I always do try codex but I get lost in the terminology

    $post is a variable, do I need to declare it? or do I need to declare post_parent?
  • Ah kewl, got it, thanks for the post