Show a List of Previous Posts in Sidebar

I'm going to add a list of 15 previous posts in the sidebar. I tried using the previous posts plugin, but I kept getting syntax errors. So what I did instead was just added the following lines to my sidebar template (go to edit theme, then choose sidebar.php)

<br>
<div class="blocktitle">Recent Posts</div>
   <div class="block">
     <div class="menu">
       <ul>

            <?php
              $posts 
get_posts('numberposts=15′);
              foreach(
$posts as $post) :
            
?>
      <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
      <?php endforeach; ?>
      
       </ul>
      </div>
   </div> 

You can just copy-paste the above into your theme editor. Don't worry about the colors - they're just code highlighting done by the Visual Syntax plugin. I inserted the code just above the following line:

<!– Monthly Archives –>

..so it appears just where I want it. Voila!




Google
 
Web innerblogger.com




Leave a Reply