Grow your CSS skills. Land your dream job.

How do I show a pages sub-pages in WordPress

  • # June 30, 2009 at 2:45 pm

    As stated in the post’s topic, i was wondering if someone knew how to list sub-pages of a page within the same page. For example, I would like a page named products to list a bunch of products by a certain company, and when more products are added as a sub-page of the products page, the list gets updated to reflect the change. I’m there’s a single wp tag that would do this, so please forgive my stupidity for not knowing this.

    Many thanks in advance for your help.

    # June 30, 2009 at 2:54 pm

    The best place to start is always the codex http://codex.wordpress.org/Template_Tags/wp_list_pages#List_subpages_even_if_on_a_subpage

    This is what you are looking for

    Code:
    < ?php
    $children = wp_list_pages('title_li=&child_of='.$post->ID.’&echo=0′);
    if ($children) { ?>

      < ?php echo $children; ?>

    < ?php } ?>

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".