Change Excerpt Length

I am trying to change the excerpt length using the folllowing function in my child theme but it shows me no effect.
function custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
After that i also tried to edit the excerpt length in theme-option.php file in muffin-options but it also shows no effect.
So please let me know how can i change the excerpt length of my posts.

Comments

  • Ok but you want to change excerpt for what?
  • I want to change excerpt for the posts that appear on my category page. ?
  • The function that you should to change is functions/theme-functions.php file and modified must be below code:
    function mfn_excerpt_length( $length ) {
        return 26;
    }
    add_filter( 'excerpt_length', 'mfn_excerpt_length', 999 );
    26 means that inside excerpt will be 26 words so you can replace this value with any like you want. But what is much better way is setup own excerpt for each post. While you create/edit post, under Post options you have field called "Excerpt" and inside you can but any excerpt you want and then this value will be used as default. If you don`t have this field, then you must click on "Screen options" button in right top corner and check "Excerpt" to show.

    Hope this will help you a lot.
Sign In or Register to comment.