Support » Fixing WordPress » Help with listing child pages in sidebar menu

  • I’m new to WordPress and PHP, so I’m still in the baby steps phase. I’ve been trying unsuccessfully to create a dynamic menu in sidebar.php. This is what I want:

    Services
    Page ID4
    Child1 of ID4
    Child2 of ID4

    Seems simple enough. Based on the Codex, I came up with the following:
    <?php wp_list_pages('include=4&title_li=<h2>Services</h2'); ?>

    But all I get it the parent, and no children. I also tried the following variations with the exact same result:

    <?php wp_list_pages('include=4&depth=0&title_li=<h2>Services</h2'); ?>
    <?php wp_list_pages('include=4&depth=-1&title_li=<h2>Services</h2'); ?>

    Could someone tell me what I’m doing wrong? I noticed that podcastjunky posted the same question here (http://wordpress.org/support/topic/137851?replies=2), but the fix suggested for him/her doesn’t seem to apply for me.

    I’m using the Atmosphere theme.

Viewing 2 replies - 1 through 2 (of 2 total)
  • With include=4, only the page with ID 4 will be included, nothing else. Instead, use include=4,5,6 (use whatever IDs you want). Also, the closing </h2 in your code is missing an end >

    http://codex.wordpress.org/wp_list_pages

    Thread Starter sunada

    (@sunada)

    Well, yes, I realize I can list the specific child pages individually, but shouldn’t the depth parameter bring in the child pages (to whatever depth I specify) without my having to list each one individually? I’d like it to be dynamic!

    And thanks for spotting the missing closing tag. Just fixed that.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Help with listing child pages in sidebar menu’ is closed to new replies.