Problem: I would like to show the post excerpt if it is not empty, otherwise show the full post content.
Solution:
The wpv-post-excerpt shortcode utilizes WordPress's the_excerpt function to display a post excerpt. This means that you cannot expect wpv-post-excerpt to be empty if the post contains any content. Instead, you could add this custom shortcode to your child theme's functions.php file:
add_shortcode('wpv-post-real-excerpt', 'real_excerpt_shortcode'); function real_excerpt_shortcode() { global $post; return $post->post_excerpt; }
Go to Toolset > Settings > Frontend Content and enter "wpv-post-real-excerpt" in the 3rd party shortcodes area. Then you should be able to test the excerpt like this:
[wpv-conditional if="('[wpv-post-real-excerpt]' != '')"] [wpv-post-excerpt] [/wpv-conditional] [wpv-conditional if="('[wpv-post-real-excerpt]' != '')" evaluate="false"] [wpv-post-body view_template='None'] [/wpv-conditional]
Relevant Documentation:
https://developer.wordpress.org/reference/functions/the_excerpt/
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-excerpt
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by 6 years, 9 months ago.
Assisted by: Christian Cox.