Problem: I would like to use conditional HTML to test whether or not the post content is empty.
Solution: You can use a custom function to test if the body contents are empty:
function wpv_conditional_post_has_content($type, $object) { $return = 0; if ( $type == 'posts' ) { if ( empty( $object->post_content ) ) { $return = 0; } else { $return = count($object->post_content); } } return $return; }
Go to Toolset > Settings > Frontend Content > Functions inside conditional evaluations, and enter wpv_conditional_post_has_content to register this function for use in conditionals.
Then you can use the function in a conditional like this:
[wpv-conditional if="( wpv_conditional_post_has_content() eq '1' )"] <a href="#person-gallery"><button type="button" class="btn btn-primary">[wpml-string context="Person Gallery Anchor" name="Person Gallery Anchor"]الصور / الأيقونات المتاحة[/wpml-string]</button></a> [/wpv-conditional]
Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
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, 5 months ago.
Assisted by: Christian Cox.