• Resolved giltrap

    (@giltrap)


    I have written a story that I want to post on pages in my blog, one chapter per page.

    What I want to be able to do is have a page that is the parent of all the chapters to act as a contents page of sorts and that it sort of updates on it’s own whenever I add a child page. I don’t want to have to manually add every single chapter as I write it as there are over 20. I don’t however want every page in my website to display it’s child page, only this particular contents page.

    Also, if I could order it in different ways, like in order of when I post them or maybe a custom order then that would be great too. That way I could make everything appear in the right order.

    Apologies if this post is a bit incoherent, it’s 03:00 here and I’m a bit tired. Thanks for your time.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Add this to your page.php

    <?php $sub_pages = wp_list_pages( 'sort_column=menu_order&depth=3&title_li=&echo=0&child_of=' . $id );?>
    <?php if ($sub_pages <> "" ){?>
    <p class="post-info">This section has the following sub pages.</p>
    <ul><?php echo $sub_pages; ?></ul>
    <?php }?>

    You can change the text “This section has the following sub pages.” to whatever you like. Remember to pick the “Parent Page” of sub page in dropdown box. Then, to make sub pages appear in the order you want them to, number the page in “Page Order” box of Write Page panel, e.g.
    1000 – Chapter 1
    1010 – Chapter 1 sub page 1
    1020 – Chapter 1 sub page 2
    2000 – Chapter 2
    2010 – Chapter 2 sub page 1
    etc.

    Thread Starter giltrap

    (@giltrap)

    I’ve done that, and it sort of works.

    However, on all of my other pages that have subpages, the list of subpages also appears, which I don’t need. How do I make it so that I only have the list of subpages in my contents page?

    Thanks

    Open up your page.php and save as page-content.php in your theme folder. Open up page.php and delete the code I gave you, save and FTP upload to your themes folder.

    Open up page-content.php and add this at the very top

    <?php
    /*
    Template Name: Contents
    */
    ?>

    – with the code I gave you still intact. Save and FTP upload to your theme folder. In Page > Add New panel, there will be a dropdown box for Page Template and you choose “Contents” whenever you are creating the Contents page. For your subpages, you use the regular page.php so you don’t need to choose anything in the dropdown box.

    Thread Starter giltrap

    (@giltrap)

    After looking a bit harder than I did at first, I’ve managed to find a plugin that does what I wanted to do.
    Subpage Listing

    Thanks for your help anyway.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘List of child pages of a page, table of contents style.’ is closed to new replies.