Modify wordpress Custom excerpt length

Modify wordpress Custom excerpt length

In wordpress api we having the the_excerpt method for showing the short description from wordpress post.
On WordPress 2.9 there are new featured that we can added on the_excerpt(), one of them is change the excerpt length.

Modify wordpress Custom excerpt length

For Modify wordpress Custom excerpt length we need use the filter for modify the wordpress excerpt length. Use our custom code and put in functions.php file

For changing the length of excerpt we need use the filter for modify the wordpress excerpt length.
We only needed to put some function on our functions.php themes file and added some hook to call this functions.

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

Using above code you can control the character length in wordpress description.

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.