Modify Custom excerpt length


Sponsored Links




wordpress-custom-excerpt-lengthOn WordPress 2.9 there are new featured that we can added on the_excerpt(), one of them is change the excerpt length. How to modify Custom excerpt length is really simple. We only needed to put some function on our functions.php themes file and added some hook to call this functions.

Write down Custom excerpt length below

<?php
// Add custom excerpt length
function custom_excerpt_length($length) {
	return 20;
}
add_filter('excerpt_length', 'custom_excerpt_length');
?>

And done, you have new excerpt length, please note you can modify the value of 20, you can added whatever you want. Or if you want totally new version and using your own excerpt, you can follow our tutorial to create Own Excerpt in WordPress. You can tried using plugin on this method

Subscribe to Full RSS Feed

RSS FeedIf you thing this article useful, please consider subscribing to our RSS Feed or e-mail updates and stay updated with us. You can also follow @WPTricksNet on twitter for latest updates.

About WP Tricks

We are WordPress Family, we collected and writed useful tips and tricks for you WordPress. We share it for you...

Related Tips and Trick from Local Data and on The Net


4 Responses to Modify Custom excerpt length

  1. anar says:

    Help please,
    i keep getting this error. i am using thesis theme and this is how my functions are

    add_filter(‘the_excerpt’, ‘my_excerpts’);
    // Function to replace ellipsis with text
    function my_excerpt($text) {
    return str_replace(‘[...]‘, ”, $text);
    }

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘my_excerpts’ not found or invalid function name in C:\xampp\htdocs\wordpress\wp-includes\plugin.php on line 166

    • nobody says:

      @anar
      You used ‘my_excerpts’ plural in the add_filter call, but you defined function my_excerpt singular (without the ‘s’).

  2. Documentare says:

    Thanks for help. I’ve solved the problem.

  3. [...] How to modify Custom excerpt length on WordPress # WordPress Tricks & Tips [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>