


For this purpose, there are already plenty of plugins and widgets that provide this functionality, but it's just without the use of additional plugins. A code snippet that shows the last article of your blog, you will find in this article.

The code to determine the last item


function get_latest_posts($limit = 3)
$latest_posts = get_posts('numberposts=' . $limit);

$output = '<ul>';
foreach($latest_posts as $post)
$post_title = $post->post_title;
$post_permalink = get_permalink($post->ID);

$thumbnail = get_the_post_thumbnail(
'class' => '',
'alt' => $post_title,
'title' => $post_title

$output .= '<li><a href="' . $post_permalink . '" title="Artikel: ' . $post_title . '">';
$output .= $thumbnail . '<span>' . $post_title . '</span></a></li>';

$output .= '</ul>';

return $output;



The code to display the last items


1.echo  get_latest_posts (7);



Leave a reply
