function set_excerpt_length() {
return 20; // Sets the automatic excerpt length to 40 words
}
add_filter('excerpt_length', 'set_excerpt_length');
function new_excerpt_more($more) {
return '...'; // Change to whatever you want the 'read more' text to be.
}
add_filter('excerpt_more', 'new_excerpt_more');
Here’s how to use it:
echo wp_kses_post(get_the_excerpt());
Have any questions or comments? Write them below!