Display Recent Posts in WordPress Home Page only

If you need to display your recent posts in the front page of your blog and nowhere else, you don’t need (and perhaps you won’t even find) a dedicated plugin / widget for that.

Here is my code; feel free to copy, modify and use it to show your recent 5 posts. Changing this number you can show less or even more:

if (is_front_page() || is_home()) {
echo '<h3>Write Here the Title for your Recent Posts list</h3><div class="AnyStyleYouLike"><ul>';
$query = new WP_Query(array(
'posts_per_page' => 5,
while ($query->have_posts()): $query->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; 
echo '</ul></div>';