WordPress.org

Ready to get started?Download WordPress

Forums

Spawning Child Page Links on Parent Page (6 posts)

  1. Ecko
    Member
    Posted 6 years ago #

    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)

    <?php
    $children = wp_list_pages("title_li=&child_of=".$post->ID.
    "&sort_column=menu_order&show_date=modified".
    "&date_format=$date_format&echo=0");
    if ($children) { ?>

      <?php echo $children; ?>

    <?php } ?>

    Into the parent page.

    Any help would be greatly appreciated.

    TIA

  2. Alex Cragg
    Member
    Posted 6 years ago #

    you need to put this in you page template, the php file as opposed to the content.

  3. Ecko
    Member
    Posted 6 years ago #

    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 :)

  4. khethridge
    Member
    Posted 6 years ago #

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

  5. Ecko
    Member
    Posted 6 years ago #

    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 :)

  6. Ecko
    Member
    Posted 6 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic