Forums

[resolved] Showing excerpt with wp_list_pages (4 posts)

  1. g0dzuki
    Member
    Posted 1 year ago #

    Hi -- I have a page template that shows a list of sub-pages for a given parent page. I'd like it to show an excerpt or a preview of each sub-page listed.

    Looking at the docs for wp_list_pages - it doesn't look like there's an argument for it.

    Is there a way to do this or maybe a plug-in that anyone knows about?

    Thanks!

    - Chris

  2. MichaelH
    moderator
    Posted 1 year ago #

    You'll have to use the template tag, query_posts(), with parameters like 'post_type=page&post_parent=47' in your page template and then use the_excerpt() in your loop.

    Assuming your page parent id is 47, here's an example loop:

    <?php $page_query = new WP_Query('post_type=page&post_parent=47'); ?>
    <?php while ($page_query->have_posts()) : $page_query->the_post(); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    <?php endwhile; ?>
  3. mores
    Member
    Posted 1 year ago #

    Didn't Mushu say WP wasn't made for this ;)

    Thanks, this is exactly what I've been looking for, but in a "if child pages then show else do nothing" fashion. Will post code once I get it to work.

  4. g0dzuki
    Member
    Posted 1 year ago #

    Exactly what I was looking for -- thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic