Skip to content

WordPress – Custom length excerpt

If you ever need a custom length excerpt in your wordpress site, and want to leave the excerpt length alone for the rest of the site, you can use wp_trim_words on the content to pull out exactly how many words you want the excerpt to be.

In the following example I made a 10 words excerpt, but you can make it any length you want by changing the number.

<?php echo wp_trim_words(get_the_content(), 10); ?>

Published inPHPScripting

Be First to Comment

Leave a Reply

Your email address will not be published.