Enhance WordPress Excerpt by Simple Functions

AD

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
Leave a Reply

avatar
1 Comment threads
2 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
3 Comment authors
LoganskyjeCeline Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Celine
Guest

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