what are you using to display the posts, a plugin, if so which one? If not, what wordpress function?
Sorry for my delayed response, it’s been too nice outside here in Seattle to stay online! Here is what I am using:
<?php
foreach ($recentposts as $post) {
if ($post->post_title == '')
$post->post_title = sprintf(__('Post #%s'), $post->ID);
echo "<li><a href='".get_permalink($post->ID)."'>";
the_title();
echo '</a></li>';
}
?>
I’d like to limit the number of words that are displayed in the title, in the sidebar only, but not on the post’s page itself – limit it to what will fit on one line… not just truncate it to a certain character count; that’s easy.
Like I said in my first post, if I have six words in the title but only four fit on a line before it is wrapped to the next line, I’d like it to stop after the fourth word and ad an ellipse (…) so if it is set to 31 characters maximum, it would change:
WordPress Issues World Wide Press Release
to
WordPress Issues World Wide…
but not just like 31 characters like this:
WordPress Issues World Wide Pre
So it finds 31 characters, then goes back to the end of the last word, and stops there and adds an ellipse, any ideas?
i’ve got the same problem. anybody an idea?
I would love some help with this as well.
ok i’ve got it working on my site
<?php $my_query = new WP_Query('showposts=7');
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php
if (strlen(the_title('','',FALSE)) > 40) {
$title_short = substr(the_title('','',FALSE), 0, 40);
preg_match('/^(.*)\s/s', $title_short, $matches);
if ($matches[1]) $title_short = $matches[1];
$title_short = $title_short.' ...';
}
else
{
$title_short = the_title('','',FALSE);
}
?>
<a title="<?php echo the_title() ?>" href="<?php the_permalink() ?>"><?php echo $title_short ?></a><br>
<?php endwhile; ?>