function wpv_conditional_post_has_excerpt($type, $object) {
$return = 0;
if ( $type == 'posts' ) {
if ( empty( $object->post_excerpt ) ) {
// return 0 when post's excerpt is empty
$return = 0;
} else {
// return 1 when post's excerpt is not empty
$return = 1;
}
}
return $return;
}
```
All this below shortcode showing posts in loop returns nothing
```
[wpv-conditional if="( wpv_conditional_post_has_excerpt() eq '1' )"]
<p> I have an excerpt </p>
[wpv-post-excerpt output="raw"]
[/wpv-conditional]
[wpv-conditional if="( wpv_conditional_post_has_excerpt() eq '0' )"]
<p>I have no excerpt</p>
[/wpv-conditional]
```
Please let me know about the obvious things i'm missing!
Oh here's a debug message if that helps?
Only some of your content has manual excerpts, and you are adopting a solution to output the manual excerpt if it exists but the post content if it doesn't, is that right?
I'm not sure you need such an elaborate solution.
The wpv-post-excerpt shortcode already outputs the manual excerpt if it exists and an automatic excerpt if it doesn't.
You can set the word length of the excerpt to an arbitrarily high value if you want all of the content to be output.
Oh, you're quite right!
[wpv-post-excerpt] should do this job already,
but I've broken it by replacing wp_trim_excerpt()
in order to include some links and other tags in the excerpt, as that's in the content that needs to be migrated.
Would you be able to suggest a better way to allow <a><br> in the manual excerpts without breaking [wpv-post-excerpt?
Based on what you've shared, I'll recommend not to use the 'get_the_excerpt' filter, as it affects the excerpts functionality globally, including for the 'wpv-post-excerpt' shortcode.
Instead, you can register a custom shortcode, that can be used specifically wherever you'd like to display the excerpts/trimmed content with the selected HTML tags allowed: https://codex.wordpress.org/Shortcode_API
The logic of the output of this custom shortcode would be very similar to the 'improved_trim_excerpt' function that you already have. But, it just won't be filtering the excerpts, in general through the 'get_the_excerpt' filter.
I hope this helps and please let me know if you need further assistance.