$excerpt_length = 15; // words $thumbnail_size = 'thumbnail'; $number_of_posts = 5; $args = array( 'numberposts' => $number_of_posts, // number of posts 'post_status' => 'publish' ); $recent_posts = wp_get_recent_posts( $args, ARRAY_A ); foreach( $recent_posts as $recent ) { $permalink = get_permalink( $recent['ID'] ); $post_title = esc_attr( $recent['post_title'] ); if ( empty( $recent['post_excerpt'] ) ) { $the_excerpt = strip_tags( strip_shortcodes( $recent['post_content'] ) ); $words = explode( ' ', $the_excerpt, $excerpt_length + 1 ); if ( count( $words ) > $excerpt_length ) { array_pop( $words ); array_push( $words, '…' ); $the_excerpt = implode( ' ', $words ); } } else { $the_excerpt = $recent['post_excerpt']; } // Open block echo '
'; // Thumbnail if ( has_post_thumbnail( $recent['ID'] ) ) { printf( '%3$s', $permalink, $post_title, get_the_post_thumbnail( $recent['ID'], $excerpt_length ) ); } // Title printf( '

%2$s

', $permalink, $post_title ); // Excerpt printf( '

%1$s

', $the_excerpt ); // Close block echo '
'; } // END foreach