Skip Navigation

[Resolved] User Post Body in a HTML conditional

This thread is resolved. Here is a description of the problem and solution.

Problem:
How can I check if the Post Body is empty, in a View?

Solution:
This requires a additional Custom PHP function registered in Toolset > Settings > Frontend Content > 3rd party Functions

It's elaborated in detail here:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-custom-functions-in-conditions/ > Checking For Empty Post Content

This support ticket is created 7 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

Our next available supporter will start replying to tickets in about 1.04 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 3 replies, has 2 voices.

Last updated by kelvinL-2 7 years, 11 months ago.

Assisted by: Beda.

Author
Posts
#406490
Screen Shot 2016-06-13 at 12.36.33 PM (2).png
Screen Shot 2016-06-13 at 12.40.15 PM (2).png
Screen Shot 2016-06-13 at 2.24.17 PM (2).png

Dear Sir/Madam,

I use Views and Content Template to display specific custom post with Layout. I set the conditional to check whether the post-body is empty or not and display the content.

[wpv-conditional debug="true" if="('[wpv-post-body view_template='None']' ne '')"]
<div id="caption-container">  
[wpv-post-body view_template='None']
</div>
[/wpv-conditional]

I have two posts and both contain the content in post-body but only one show the content.

From screenshot with cat is the post can display the post-body, from screenshot with two hosts, you should able to see the content from Dashboard but not content display.

Is there any limitation to the conditional check?

Best regards,

Kelvin.

#406498
Screen Shot 2016-06-13 at 3.06.52 PM (2).png

Dear Sir/Madam,

FYI. I can see content query from the debug but don't know why it cannot be showed.

Best regards,

Kelvin.

#406654

1. I set the conditional to check whether the post-body is empty or not and display the content.

This requires a additional Custom PHP function registered in Toolset > Settings > Frontend Content > 3rd party Functions

It's elaborated in detail here:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-custom-functions-in-conditions/ > Checking For Empty Post Content

#406665

Dear Beda,

Excellent! Problem fixed.

Best regards,

Kelvin.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.