Forums

Use the_excerpt in wp_list_pages (2 posts)

  1. steighne
    Member
    Posted 2 years ago #

    so....
    trying to do this...

    Show an excerpt from all Pages as either text or link_after to include img, a, strong, em tags (et al general html).

    My attempt to do this is in the header where the menu is now formatted to show the names of the pages and their corresponding excerpt in a series of divs that look like buttons rather than the typical horizontal menu (formatted to show normally on all of the pages _except_ the front page).

    I've installed a plugin (against my will, WP!) to show excerpts on Pages and want to incorporate that content (the_content) or excerpt (the_excerpt) on the front page just after the title...
    check out the code...

    <?php
    wp_reset_query();
    if (is_front_page())
    	{ echo '<div id="band"> <ul id="main-nav" class="right">
    		<ul>',(wp_list_pages(title_li=&link_after=<?php the_excerpt; ?>));
    	}
    else
    	{ echo '<div id="menu"> <ul id="main-nav" class="right">
    		<ul>',(wp_list_pages('title_li'));
    	}
    ?>
    </div></ul>

    To output something like this:

    <div><ul><li><a>Page1 Title the content of page1 or the excerpt from that page</a></li></ul></div>
    <div><ul><li><a>Page2 Title the content of page2 or the excerpt from that page</a></li></ul></div>
    <div>...etc
  2. MichaelH
    Volunteer
    Posted 2 years ago #

    You'll need to use get_pages or a query posts loop for that. Leaving the formatting to you, but here's an example using a new query.

    <?php
    $args=array(
      'post_type' => 'page',
      'post_status' => 'publish,private',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
        the_excerpt();
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic