WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted limited excerpt (40 words) with readmore link...I used this code below:

<?php echo apply_filters('the_excerpt',get_the_excerpt().'<a href="'.get_permalink().'"> read more </a>'); ?>

any help appreciated.

share|improve this question
You've got the answers, but you can always refer to the_excerpt(); on WP Codex. – its_me Jul 16 '12 at 8:38
No question in this question. – toscho Jul 16 '12 at 9:42

You can use the default filter for the length of the_excerpt

// Changing excerpt length
function new_excerpt_length($length) {
    return 40;
add_filter('excerpt_length', 'new_excerpt_length');
share|improve this answer
thanks bueltge, It' not working...because my code...can u tell me what's wrong... My code is: <?php $text = $post->post_excerpt;if (strlen($text) > 40) { $text = substr($text,0,strpos($text,' ',40)); } ; $text = $text . ''; echo apply_filters('the_excerpt',get_the_excerpt().'<a href="'.get_permalink().'"> Read More </a>'); ?> please help me... – Gopal Bhattacharjee Jul 20 '12 at 16:34
all your code is wrong for your question; use my code on the answer and put in a plugin or copy in your functions.php of your theme and it works. – bueltge Jul 23 '12 at 13:38

Just an addition to Bültge's answer. You can also alter the "Read more" text:

function replaceMoreText() {
    global $post; // may be you don't need this, it depends
    return '<p class="new-read-more-text"><a href="'. get_permalink($post->ID) . '">' . __('New read more text') . '</a></p>';
add_filter('excerpt_more', 'replaceMoreText');
share|improve this answer

thanks everybody,

I solved my problem....

in function.php

function get_excerpt($count){
$permalink = get_permalink($post->ID);
$excerpt = get_the_content();
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, $count);
$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
$excerpt = $excerpt.'... <a href="'.$permalink.'">Read More</a>';
return $excerpt;

in category.php

<?php echo get_excerpt(40); ?>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.