Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have following code in my .php file:

$my_pages = wp_list_pages("title_li=&child_of=".$my_id."&echo=0");

Then I create an <ul>

<ul>
  <?php echo $my_pages; ?>
</ul>

Problem is, that I would like to list a title in <h2> tag, and excerpt of the page on the text below. It´s possible to do that using wp_list_pages?

share|improve this question
    
You should instead consider WP_Query(), but if you must use wp_list_pages(), you should check how to use it with a custom walker. –  birgire Apr 18 '13 at 20:57

1 Answer 1

up vote 0 down vote accepted

No, it is not possible. you will want to use WP_Query()

Here is the Codex Article on that.

Example:

<?php

// Query All Pages
$my_query = new WP_Query( 'post_type=page' );

// The Loop
while ( $my_query->have_posts() ) :
    $my_query->the_post();
    echo '<h2>' . get_the_title() . '</h2><p>' . get_the_excerpt() . '</p>';    
endwhile;

?>
share|improve this answer
2  
A call to wp_reset_postdata after the loop would be beneficial. –  Johannes Pille Apr 18 '13 at 20:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.