• Hi and thanks to everyone that contributes to WordPress!

    Is it possible to list pages AND subpages by their ID number? I need a list of tips(pages and subpages)that I want to appear in the sidebar, but aparently wp_list_pages() will list only pages but not subpages by their ID number.

    For example:

      <?php
      wp_list_pages(‘include=5,9,23&title_li=<h2>’ . __(‘Poetry’) . ‘</h2>’ ); ?>

    will not display page 23 name if page 23 is a subpage. Any ideas how to display subpage 23 also?

    Thank You Very Much!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Cathy Mitchell

    (@multitalentedmommy)

    The code you have you will list pages with the id of 5,9, and 23. And you have given the list a custom title. That code will display Page 23, no matter where it stands in the Page hierarchy. Is that not what you want? Or is the code not doing what you expected?

    Thread Starter chippeterson

    (@chippeterson)

    That is the point, wp_list_pages() will only display pages by ID number, but not subpages. It will only display page 5 and 9 but not 23 which it is a subpage in my particular case.

    I appreciate it.

    Cathy Mitchell

    (@multitalentedmommy)

    If the ID of the SUBPAGE is 23, then the code above will work. Just to try again:
    <?php wp_list_pages('include=9,5,23&blah, blah');?>

    I tested it on my site. My code looks like this:
    <?php wp_list_pages('title_li=&depth=1&include=40,15'); ?>
    – this displays page 40, and Page 15 (which is a subpage of Page##)
    – the depth parameter use is shown here.

    Cathy Mitchell

    (@multitalentedmommy)

    Double check this:
    Is the page id right? Is the page marked “private”? Is it published or just saved?

    The ID based parameters (exclude, include) do NOT care whether it is a parent or sub-Page. The code you posted should work. There must be something else wrong with it.

    Cathy Mitchell

    (@multitalentedmommy)

    lol – how do you ever encapsulate so much in so few words? I’m in awe. ??

    ??
    In my previous life when I was a journalist I was taught that he who writes long… is capabable of other crimes, too!

    Thread Starter chippeterson

    (@chippeterson)

    If the parent of page 23 is not in the list the page 23 will not pe displayed. Here is the code, I tested 5 times:

    <?php
    wp_list_pages(‘include=5,9,13,23&title_li=<h2>’ . __(‘Poetry’) . ‘</h2>’ ); ?>

    This will display all 4 pages because 13 is a parent of 23.

    <?php
    wp_list_pages(‘include=5,9,23&title_li=<h2>’ . __(‘Poetry’) . ‘</h2>’ ); ?>

    This will display only 5 and 9 because 13, the parent of 23, is not in the list.

    Is it possible to display only 23 but not it’s parent 13?

    Thread Starter chippeterson

    (@chippeterson)

    I stand corrected: seemingly you discovered a bug!
    The include parameter is ineffective for sub-Pages if their parent is not included, too. (Just tested…)

    You may want to consider reporting it to the trac.

    Thread Starter chippeterson

    (@chippeterson)

    Thank You. Do I have any other option not to list the parent? Is the only solution to insert the links one by one, manually?

    If they will fix it, what should I do next? I’m not sure how this works.

    Cathy Mitchell

    (@multitalentedmommy)

    Moshu, test again! I thought i tested this on my localhost last night, and was able to view a subpage without its parent page listed.

    I’m trying it again, but can’t get the stupid localhost to let me into wordpress…errrrrr. (Emergency.php isn’t working either).

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘List subpages by ID’ is closed to new replies.