PHP Editing

Got a Wordpress theme that I’m trying to edit. So far it’s gone ok but I’m stuck on the recent posting section.

Here’s the PHP document.


<!-- begin sidebar -->


<div id="menu">


<ul>
<table cellspacing="0" cellpadding="0" width="200px" style="margin-top:5px;">
<tr><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rulu.gif" alt="rulu"></td><td class="z1"></td><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/ruru.gif" alt="ruru"></td></tr>
<form id="searchform" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<tr class="z1"><td class="z1"></td><td>
<table cellspacing="0" cellpadding="0" class="n1" width="100%">
<tr valign="top"><td class="grrlu"></td><td  class="grrru"></td></tr>
<tr><td align="center"><input type="text" name="s" id="s" /></td><td><input type="image" src="<?php bloginfo('stylesheet_directory'); ?>/images/search.gif" /></td></tr>
</table>
</td><td class="z1"></td></tr>
</form>
<tr height="7px"><td><img src="<?php bloginfo('stylesheet_directory'); ?>/images/ruld.gif" alt="ruld"></td><td class="z1"></td><td><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rurd.gif" alt="rurd"></td></tr>
</table>
<? if ($pages_html=wp_list_pages("echo=0") ){ ?>
<table cellspacing="0" cellpadding="0" width="200px" style="margin-top:5px;">
<tr><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rulu.gif" alt="rulu"></td><td class="z1"></td><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/ruru.gif" alt="ruru"></td></tr>
<tr class="z1"><td class="z1"></td><td>
<table cellspacing="0" cellpadding="0" class="n1" width="100%">
<tr valign="top"><td class="grrlu"></td><td  class="grrru"></td></tr>
<tr><td colspan="2"><?=$pages_html?></td></tr>
</table>
</td><td class="z1"></td></tr>
<tr><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/ruld.gif" alt="ruld"></td><td class="z1"></td><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rurd.gif" alt="rurd"></td></tr>
</table>


<?php
}
 ?>

<table cellspacing="0" cellpadding="0" border="0" width="200px" style="margin-top:5px;">
<tr><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rulu.gif" alt="rulu"></td><td class="z1"></td><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/ruru.gif" alt="ruru"></td></tr>
<tr class="z1"><td class="z1"></td><td>
<table cellspacing="0" cellpadding="0" class="n1" width="100%">
<tr valign="top"><td class="grrlu"></td><td  class="grrru"></td></tr>
<tr><td colspan="2">
 <li id="categories"><?php _e('Categories:'); ?>
	<ul>
	<?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>
	</ul>
 </li>
</td></tr>
</table>
</td><td class="z1"></td></tr>
<tr><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/ruld.gif" alt="ruld"></td><td class="z1"></td><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rurd.gif" alt="rurd"></td></tr>
</table>

<table cellspacing="0" cellpadding="0" border="0" width="200px" style="margin-top:5px;">
<tr><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rulu.gif" alt="rulu"></td><td class="z1"></td><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/ruru.gif" alt="ruru"></td></tr>
<tr class="z1"><td class="z1"></td><td>
<table cellspacing="0" cellpadding="0" class="n1" width="100%">
<tr valign="top"><td class="grrlu"></td><td  class="grrru"></td></tr>
<tr><td colspan="2">
 <li id="archives"><?php _e('Activity'); ?>
 	<ul>
	 <?php
						$posts = get_posts('numberposts=5&offset=0');
						foreach ($posts as $post) :
					?>
					<li>
					<a href="<?php the_permalink(); ?>" title="<?php the_title() ?>"><?php the_title() ?></a>
					</li>
					<?php
						endforeach;
					?>
 	</ul>
 </li>
</td></tr>
</table>
</td><td class="z1"></td></tr>
<tr><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/ruld.gif" alt="ruld"></td><td class="z1"></td><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rurd.gif" alt="rurd"></td></tr>
</table>

<table cellspacing="0" cellpadding="0" border="0" width="200px" style="margin-top:5px;">
<tr><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rulu.gif" alt="rulu"></td><td class="z1"></td><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/ruru.gif" alt="ruru"></td></tr>
<tr class="z1"><td class="z1"></td><td>
<table cellspacing="0" cellpadding="0" class="n1" width="100%">
<tr valign="top"><td class="grrlu"></td><td  class="grrru"></td></tr>
<tr><td colspan="2">
 <li id="archives"><?php _e('Archives:'); ?>
 	<ul>
	 <?php wp_get_archives('type=monthly'); ?>
 	</ul>
 </li>
</td></tr>
</table>
</td><td class="z1"></td></tr>
<tr><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/ruld.gif" alt="ruld"></td><td class="z1"></td><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rurd.gif" alt="rurd"></td></tr>
</table>

<table cellspacing="0" cellpadding="0" border="0" width="200px" style="margin-top:5px;">
<tr><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rulu.gif" alt="rulu"></td><td class="z1"></td><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/ruru.gif" alt="ruru"></td></tr>
<tr class="z1"><td class="z1"></td><td>
<table cellspacing="0" cellpadding="0" class="n1" width="100%">
<tr valign="top"><td class="grrlu"></td><td  class="grrru"></td></tr>
<tr><td colspan="2">
 <li id="categories"><?php _e('Links:'); ?>
	<ul>
	<?php get_links('-1', '<li>', '</li>', '', 0, 'name', 0, 0, -1, 0); ?>
	</ul>
 </li>
</td></tr>
</table>
</td><td class="z1"></td></tr>
<tr><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/ruld.gif" alt="ruld"></td><td class="z1"></td><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rurd.gif" alt="rurd"></td></tr>
</table>

<table cellspacing="0" cellpadding="0" border="0" width="200px" style="margin-top:5px;">
<tr><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rulu.gif" alt="rulu"></td><td class="z1"></td><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/ruru.gif" alt="ruru"></td></tr>
<tr class="z1"><td class="z1"></td><td>
<table cellspacing="0" cellpadding="0" class="n1" width="100%">
<tr valign="top"><td class="grrlu"></td><td  class="grrru"></td></tr>
<tr><td colspan="2">
 <li id="meta"><?php _e('Meta:'); ?>
 	<ul>
		<?php wp_register(); ?>
		<li><?php wp_loginout(); ?></li>
		<li><a href="feed:<?php bloginfo('rss2_url'); ?>" title="<?php _e('Syndicate this site using RSS'); ?>"><?php _e('<abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
		<li><a href="feed:<?php bloginfo('comments_rss2_url'); ?>" title="<?php _e('The latest comments to all posts in RSS'); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
		<li><a href="http://validator.w3.org/check/referer" title="<?php _e('This page validates as XHTML 1.0 Transitional'); ?>"><?php _e('Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr>'); ?></a></li>
		<li><a href="http://www.stealthsettings.com/" title="<?php _e('Stealth Settings'); ?>">Stealth Settings</a></li>
		<li><a href="http://playground.laurentiupiron.com/" title="<?php _e('WP Themes'); ?>">WP Themes</a></li>
		<li><a href="http://gmpg.org/xfn/"><abbr title="XHTML Friends Network">XFN</abbr></a></li>
		<li><a href="http://wordpress.org/" title="<?php _e('Powered by WordPress, state-of-the-art semantic personal publishing platform.'); ?>"><abbr title="WordPress">WP</abbr></a></li>
		<?php wp_meta(); ?>
	</ul>
 </li>
</td></tr>
</table>
</td><td class="z1"></td></tr>
<tr><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/ruld.gif" alt="ruld"></td><td class="z1"></td><td width="7px"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rurd.gif" alt="rurd"></td></tr>
</table>

</ul>

</div>
<!-- end sidebar -->

The page is here.
www.rusmil.co.uk/blog

The aim is to show the last 5 posts on the sidebar rather than the first five posts in the blog.

Can anyone help?

not messed with WP in age tbh

but you will need to modify the… $posts = get_posts(‘numberposts=5&offset=0’);

you need a sort statement in there… but that’s about as much as I can tell you :frowning: rusty = understatement

/edit… try adding
&orderby=date&order=asc

or change asc to desc can’t remember at this time of night which away they sort

Would it be easier to add it to randomly pick out 5 posts out of all of them?