The following is a code snippet that will display the last five WordPress posts.

<?php
echo "<ul>";
$args = array( 'numberposts' => '5' );
$recentposts = wpgetrecentposts( $args );
foreach( $recent_posts as $recent ){
echo '<li><a href="' . getpermalink($recent["ID"]) . '" title="'.escattr($recent["posttitle"]).'" >' . $recent["posttitle"].'</a> </li> ';
}
echo "</ul>";
?>