Recent Posts in Sidebar without a Widget
WordPress widgets are delightful things where themes designed for public consumption are concerned. There are situations, however, where widgets aren’t in use or not practical/necessary. The code below can be added to your sidebar (or anywhere in your template, really) to display a list of current pages. I found this on an old (2007!) post at WP Garage.
<?php $myposts = get_posts('numberposts=10&offset=1'); foreach($myposts as $post): ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title();?></a></li>
<?php endforeach; ?>I’ll admit that this is used here entirely out of laziness, but I can see using this to provide a partially widgetized sidebar experience for a client site, wherein the key elements are built in to the sidebar, but the client has access to add text widgets, etc.
dani made this mess on December 31st, 2009


