
Originally Posted by
Lightfire
Hey guys,
I'm kind of new here so please apologize if i do anything wrong (since i'm from germany there could be slight mistakes with grammar or so ;) ).
I've got a 2-column wordpress blog with the posts on the left sight and a sightbar on the right. I've tried desperately to modify the sidebar so i could get 2 links in there but i failed. The links should refer to the two newest posts in one specific category.
Does anyone of you know how this would be possible? (btw. i'm still using wordpress 2.3.1 and i've got no possibility to upgrade any time soon)
Thanks a lot
You'll have to create a div container, for example:
Code:
<div id="latestposts"></div>
And then insert it into your sidebar.php file or whatever file your theme is using for the sidebar where you want the links to appear.
In the div you past this code:
PHP Code:
<ul>
<?php $recent = new WP_Query("cat=1&showposts=10"); while($recent->have_posts()) : $recent->the_post();?>
<li><a href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); ?>
</a></li>
<?php endwhile; ?>
</ul>
PHP Code:
"cat=1&showposts=10"
To change the category value just interchange "1" with the category number you want the two post from to appear.
If you want more posts simply change the "2" value to any number you want.
You'll have to style the links on your own.
If you need more help post a link to your blog or post your sidebar code and your css file's code and I would be happy to help out.