wordpress adjust excerpt length snippet

This code sets the length of the excerpt to 20 words. You can adjust the number 20 to any other value to change the length of the excerpt.

Note that this code only affects the length of the manually written excerpt. If the excerpt is automatically generated by WordPress, it may be longer or shorter than the length specified in this code. To ensure consistent excerpt length, you can use a plugin like Advanced Excerpt or a custom function that truncates the content of the post to a specific length.

function custom_excerpt_length($length) { return 20; // Change this number to adjust the length of the excerpt } add_filter('excerpt_length', 'custom_excerpt_length', 999);

Leave a Reply

Your email address will not be published. Required fields are marked *