Enhance WordPress Excerpt by Simple Functions

WordPress Excerpt is a great option needed on every theme. To Add Excerpt you can write a short summary of your post for the Excerpt field. If you choose not to write a separate excerpt, WordPress will automatically create an excerpt by truncating the first part of your post to 55 words. If you want to change the excerpt length and Remove […] string, you can use the following codes.

Control Excerpt Length using Filters

To change excerpt length using excerpt_length filter, add the following code to functions.php file in your theme:
function new_excerpt_length($length) {
return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');

Remove […] string using Filters

Only in version 2.9 and higher of WordPress
add also the following code to functions.php file in your theme:
function new_excerpt_more($more) {
return '[.....]';
}
add_filter('excerpt_more', 'new_excerpt_more');

Add “read more” link to the post

function new_excerpt_more($more) {
global $post;
return 'Read more...';
}
add_filter('excerpt_more', 'new_excerpt_more');

skyje

Skyje is a Blog for Web Designers and Web Developers featuring Social Networking news and everything that Web 2.0. You can Subscribe to Skyje feed.

You may also like...

3 Responses

  1. Celine says:

    Sorry, it didn’t show… or would it be “the_excerpt” code?

    • skyje says:

      Add above code to your functions.php page , then you can use this code to display enhanced excerpt

      • Logan says:

        yea im having the same issue, I have added the above code as well as the in the area i would like to show it and its still showing the full length

Leave a Reply