How do truncate and show read more, need help…
-
Heya, I feel like this is a really basic question and that I’m overlooking documentation but I can’t find anything on the topic. I’m writing a search.php page and I need to limit the text to a certain number of characters and show a “…” then a read more link. Can anyone help me out? Thanks!
<?php if (have_posts()) : ?> <h1>Search Results</h1> <div class="search-form"><?php get_search_form(); ?></div> <div class="navigation"> <div class="alignleft">next<?php next_posts_link('« Older Entries') ?></div> <div class="alignright">previ<?php previous_posts_link('Newer Entries »') ?></div> </div> <?php while (have_posts()) : the_post(); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> <?php echo substr($post->post_content, 0, 200); ?> <hr /> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div> <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div> </div> <?php else : ?> <h2 class="center">No posts found. Try a different search?</h2> <?php get_search_form(); ?> <?php endif; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How do truncate and show read more, need help…’ is closed to new replies.