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 am trying to get and display 5 featured posts. To achieve this target I have an offset of 5 recent posts. I have successfully fetched the posts' id's and images, but I failed to get every post's description.

I've tried the code below, but it only gives me 1 post description, not all 5 .

 $my_posts = get_posts(array('numberposts' => 5,
   'offset'      => 5,
     'orderby'     => 'post_date',
       'order'       => 'DESC',
       'post_type'   => 'post',
         'post_status' => 'publish'));

 foreach($my_posts as $post) {

$data[] = 

   "id" => $post->ID,
  "title" => $post->post_title,
  "image" => get_the_post_thumbnail($post->ID),
 // "content" =>$post['post_excerpt'] 
  "content" => apply_filters('the_content', $post->post_content)
share|improve this question
What is a "post description"? Do you mean the excerpt? The content? Or are you talking about something added by a plugin or a custom post type with custom fields? – kaiser Jun 16 '14 at 23:54
yes i am talking about "excerpt" / "content" – warzone_fz Jun 17 '14 at 4:52
Well, there is an automated excerpt which is extracted from the content and then there is the explicit excerpt, which has it's own meta box. And please file an edit for the info you are revealing. It does belong in the question, not in an comment. Thanks. – kaiser Jun 17 '14 at 8:14

Something like this should get you close (untested):

    foreach($my_posts as $post){
        $thisPostId = $post->ID;
        $thisPost = $get_post($thisPostId);
        $thisPostTitle = apply_filters('the_title', $thisPost->post_title);
        $thisPostThumbnail = get_the_post_thumbnail($thisPost);
        $thisPostContent = apply_filters('the_excerpt', $thisPost->post_excerpt);

        $data[] = array(
            "id" => $thisPost,
            "title" => $thisPostTitle,
            "image" => $thisPostThumbnail,
            "content" => $thisPostContent
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.