Wordpress

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');

About the author

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.

3 Comments

Click here to post a comment

Leave a Reply

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.