Skip to content

Instantly share code, notes, and snippets.

@isaacdanielanderson
Created August 14, 2018 19:46
Show Gist options
  • Save isaacdanielanderson/dc34a9cb9b6b654376b1ae9530eed977 to your computer and use it in GitHub Desktop.
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
<?php if (has_excerpt()) {
echo get_the_excerpt();
} else {
echo wp_trim_words(get_the_content(), 18);
}?>
@isaacdanielanderson
Copy link
Author

isaacdanielanderson commented Aug 14, 2018

echo wp_trim_words(get_the_content(), 18); Creates an excerpt out of the content of the custom post with the first 18 words

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment