Support » Fixing WordPress » List children on a page

  • New here, so please have mercy if this is dumb. I searched around and couldn’t find similar ?.

    I have a wordpress blog that has 4 static pages and then my posts page.
    For two of the static pages they will have children documents.

    For example one of the static pages is called Resources. For the content on the resources page I would like to have listed the title of the children docs and a brief description of them. I want all of the children to be pages, not posts.

    I can not figure out how to do this. Can someone please help?
    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • See various examples at:
    Function_Reference/get_pages

    Thread Starter zdaniel

    (@zdaniel)

    OK, I think I am almost there. Thank you so much for your help…

    I am still a bit lost.

    My code is like this:

    <?php
    
    /*
    Template Name: Resources
    */
    
    if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { die(); }
    if (CFCT_DEBUG) { cfct_banner(__FILE__); }
    
    get_header();
    ?>
    
    <div id="content">
    
    <?php
        $pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc');
        $count = 0;
        foreach($pages as $page)
        {
            $content = $page->post_content;
            if(!$content)
                continue;
            if($count >= 2)
                break;
            $count++;
            $content = apply_filters('the_content', $content);
        ?>
            <h2><a href=\"<?php echo get_page_link($page->ID) ?>\"><?php echo $page->post_title ?></a></h2>
            <div class=\"entry\"><?php echo $content ?></div>
        <?php
        }
    ?>
    </div><!--#content-->
    
    <?php
    
    get_sidebar();
    
    get_footer();
    
    ?>

    And when I do that, nothing displays. in the content section. The header, sidebar and footer are called, just no content.

    Any thoughts on where I am going wrong? Again, thanks for your time

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List children on a page’ is closed to new replies.