Created
August 14, 2018 19:46
-
-
Save isaacdanielanderson/dc34a9cb9b6b654376b1ae9530eed977 to your computer and use it in GitHub Desktop.
Great way to get custom excerpts if they exist; if not get the normal excerpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if (has_excerpt()) { | |
echo get_the_excerpt(); | |
} else { | |
echo wp_trim_words(get_the_content(), 18); | |
}?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
echo wp_trim_words(get_the_content(), 18);
Creates an excerpt out of the content of the custom post with the first 18 words