Support » Themes and Templates » Spawning Child Page Links on Parent Page

  • Morning, I have had a look but couldn’t see anything relevant.

    I have my sidebar page list set to depth 1.

    I would like to spawn a list of all child pages and links to them on each of the parent pages. I would like to do this without having to manually add a full URL link for each child entry.

    For example, I might have the sidebar page link “Hardware”.

    Clicking on this would spawn the page “Hardware” which would contain a list of a Heading plus image plus paragraph on the selected piece of hardware, the Heading linking to a child page of “Hardware” that has full details.

    From what I understand I need to enter this code on the parent page via the content editor – however my PHP code is getting stripped.

    I think what I am trying to do is add this code (from the manual)

    $children = wp_list_pages(“title_li=&child_of=”.$post->ID.
    if ($children) { ?>

      <?php echo $children; ?>

    <?php } ?>

    Into the parent page.

    Any help would be greatly appreciated.


Viewing 5 replies - 1 through 5 (of 5 total)
  • you need to put this in you page template, the php file as opposed to the content.

    hrmmm ok, so I guess then if there are no child pages then it wouldn’t appear. I was working on the principle that by adding that to a page.php would make it appear everywhere I didn’t want it too. I’ll give it a go 🙂

    Where in the page.php file do you add this?

    Ok I appear to have all of that working. Khethridge, I added the code after the closing endif; just before my post div container ended.

    Is it at all possible to work with the output, what I would like is and image, heading and summary for each child page.

    This Piece of Hardware
    [image] The X hardware is based on the blah blah and is really nice more..

    To be honest, looking at it, it’s going to be easier to manually create a list of child pages, style them up and link them using an absolute URL

    Any better ideas, feel free to share 🙂

    Surely there is some way to build a parent page of extracts from the childs?

    If I were to manually produce the links, would the the link structure remain or change if the permalink syntax was modified? Or is there usable WP syntax to create dynamically updated page links?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Spawning Child Page Links on Parent Page’ is closed to new replies.