Use a plugin π
http://mtdewvirus.com/code/wordpress-plugins/
I believe there is a native wp function somewhere, but Nick’s code works perfectly too.
Thanks, podz, but I’ve got it. For everyone else who needs it it’s this:
blockquote
<?php $latest = new WP_Query(‘showposts=5’);
while ($latest->have_posts()) : $latest->the_post(); ?>
<?php
$title = get_the_title();
if (strlen($title) >= 35)
$title = substr($title, 0, 35) . ‘…’;
?>
- “><?php echo $title; ?>
<?php endwhile; ?>
blockquote
scap that, it seems to be wrong:
<?php $latest = new WP_Query(‘showposts=5’);
while ($latest->have_posts()) : $latest->the_post(); ?>
<?php
$title = get_the_title();
if (strlen($title) >= 35)
$title = substr($title, 0, 35) . ‘…’;
?>
- “><?php echo $title; ?>
<?php endwhile; ?>
It’s also pretty easy to use wp_get_archives with type parametre set to ‘postbypost’ and limit to 5 (or so). There is even an example of this use on the template tag page (in Codex).
Of course, that doesn’t limit the title length.
err, ok, the easy way is like this though π
<?php get_archives('postbypost', 5, 'html', '', '', false) ?>
its a holdover from 1.2.* that seems to be working on my 1.5 blog
edit: yeah, what minna said! π
OK, Is there a way to add the latest entries to only the stories when you click read more? As you see in mine, the latest entries are showing on the index on every post.
I use a hack you can find here
fro, you got already the code, so you don’t really need that hack… you just inserted the code in the wrong place.
In the my-hacks.php
that you probably don’t have and have to create with the hack in it. And then upload it to, if memory serves, the root directory you have WordPress installed to. Oh, and you have to go to one of the Options panels and activate it…I can’t remember where off the top of my head, but it is called the my-hacks legacy….
But this is a LOT of work. Do you have something against plugins?
Customizable Post Listings plugin makes this SO EASY. Just activate it and put the following in your sidebar:
<li id="recent"><?php _e('Recent Articles'); ?><ul>
<?php c2c_get_recent_posts(5); ?></ul></li>
or customize the title or whatever to fit your own sidebar.
And check out http://codex.wordpress.org/Customizing_Your_Sidebar
ok – but replying to moshu – where do i put the code?
where do you want the 5 to appear?
When I click the permalink – I want it only to show up right under the body and just above the comments – no where on the main page should it show up