• Resolved lewis_j

    (@lewis_j)


    Hi

    I’m currently using the below code to display the latest 2 posts from the ‘news’ category in the sidebar.

    <h2>Latest News</h2>
    <ul><?php $temp_query = $wp_query; ?>
    <?php query_posts('cat=3&showposts=2'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
    <?php the_content(); ?>
    <?php endwhile; ?>
    <?php $wp_query = $temp_query; ?></ul>

    I would like to be able to truncate long posts to 50 characters in the side bar, add automatically add an ellipsis (…) with a ‘click here for more’ hyperlink. Is this possible?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to truncate a post for display purposes’ is closed to new replies.