I’m adding a custom column named Excerpt with Codepress Admin Columns, and would like to know specifically when the Excerpt has not been filled out. Instead WordPress shows post content automatically, if the excerpt is missing. This is also testable by switching on the “Excerpt View” from post list screen.
Implementing default_excerpt hook doesn’t seem to do anything for admin side. Grepping through codebase isn’t getting me anywhere in a reasonable amount of time so I’m asking for some help figuring this out.
Just illustrating this in full effect here with the filters and functions for both the adding of custom column and testing for excerpt existence.
Note, I’ve purposely ripped the guts out of
has_excerpt
to show you in effect what is occurring under the hood. You can use!has_excerpt
in its place.This does not take into account any efficiencies that can be had by arranging and or calling your functions by different means, this is only an example. In my test case,
…is what will be returned when no excerpt is present. Change to suit your needs.
There is
has_excerpt()
function that checks for manual excerpt.Depending on your needs you can either build column output using it for logic or hook into
the_excerpt
and blank return if current post doesn’t have manual excerpt.you can disable automatic excerpt generation from the_content via following filter hook. i personally needed it for rest api purposes and couldn’t use
has_excerpt()
in my template.remove_filter('get_the_excerpt', 'wp_trim_excerpt');