• Hello,

    I am trying to create a navigation menu for my sidebar. I would like the list to display all top-level pages by default. If there are sub-pages for the current page, I would like to display those also.

    For example, assume the home page is the current page; the list of pages should appear like:

    Home
    About
    Services

    If the about page is the current page, the list should only show the subpages of that specific page, as in:

    Home
    About
    Company Bio
    Services

    Can anyone help? I would like to achieve this without use of plugins. My dilemma is how to “break” the generation of the top-level list in order to create the child-level list. Once the child level list is created, the routine should continue parsing all other top-level pages.

    Pseudocode example:

    // Start creating a list of all top-level pages
    // Determine if the current page has children
    // If yes, create a nested list of child pages, then continue
    // Else, continue creating list of all top-level pages

    Any help would be incredibly useful. Thanks.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter jkamyck

    (@jkamyck)

    The GUI didn’t properly nest my list…I would like the list (with child pages) to appear like:

    Parent
    Parent
    >>Child
    >>Child
    Parent

    Try this:
    List subpages code

    Thread Starter jkamyck

    (@jkamyck)

    Thanks for the advice, but the suggested code only ended up listing all subpages if you were already on a subpage. If you are on a top level page, no links appear.

    I am trying to make the function recursive, with two loops…one for all top-level pages, and another one that interrupts to check for children. If there are children, the inner loop creates a list of them. The end result should look like:

    <ul>
    • Top-Level Page 1
    • <li>Top-Level Page 2 (Current Page)</li>
      <li>Current Page Child Page 1</li>
    • Current Page Child Page 2
    • </ul>
    • Top-Level Page 3
    • <li>Top-Level Page ...</li>

    In all cases, I would like the top-level pages to appear, and only the child pages for the current page. Such a seemingly simple problem is giving me quite a headache!

    Thanks to all who will offer help.

    Thread Starter jkamyck

    (@jkamyck)

    Hmm…this web interface is a little hard to use. I am trying to obtain the following:

    Parent unordered list
    Parent list item 1
    Parent list item 2 (current page, has child pages)
    Child unordered list
    Child list item 1
    Child list item 2
    Parent list item 3
    Parent list item …

    I would suggest reading the information at this link:

    http://codex.wordpress.org/Pages#Page_Templates

    … to get an idea for creating page templates; then, incorporate the information from this page:

    http://codex.wordpress.org/Template_Tags/wp_list_pages

    … to create your menu for each specific page template you created.

    Hope that helps point you in the right direction …

    Yes. Now I understand. What you want seems to be standard wordpress. You’ll just have to use the template-tag right and style your list fancy.

    Cais, how can you make your name clickable and redirectable to an URL?

    @gimliglider – scroll to the top of the page and click on “View your profile”; then, click on edit and fill in the details.

    I believe your user name becomes a link once you add in your web site link …

    Cais I’ve been trying to do it for decades but it never worked. I tried it just now but it didn’t work. anyways thanks for replying

    @gimliglider – it might have to do with my login for the codex, or maybe the extend sections, I do not recall my username originally linking … then again, sometimes I am not the most observant *grins*

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Help with list_page function’ is closed to new replies.