WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a php function that should print last three posts with title and excerpt.

For the first post printed there is no excerpt.

Here is the code:

  $posts = wp_get_recent_posts( array('numberposts' => 3, 'post_status' => 'publish')  );
  foreach ($posts as $post)
    echo "<h2 style='font-size:18px'>".$post['post_title']."</h2>";
         echo $post['post_excerpt']." <a href='".get_permalink($post['ID'])."'     style='font-size: 17px;'><b>Continue...</b></a>";
    else echo 'no excerpt';
    echo "<br><br />";

I want to show the excerpt for the first post printed too (the last posted one). What is wrong in my code? Why it's not working for the first post printed?

share|improve this question
Does "no excerpt" get output? – anu Oct 11 '12 at 21:47
make sure that the first/latest post has a custom-written excerpt. – Michael Oct 11 '12 at 22:19
up vote 1 down vote accepted

Excerpt is stored in database and available in post object only if it was added manually in post editor. Do not access such properties directly, use template tags instead - get_the_excerpt() in this case.

share|improve this answer

Your Answer


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.