Skip Navigation

[Resolved] Conditional output of wpv-post-body if it is not empty

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

Problem:
How can I display the Post Body, only if it is not empty?

Solution:
You need Custom Code, which is elaborated 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, 10 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.

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 2 replies, has 2 voices.

Last updated by henrikG 7 years, 10 months ago.

Assisted by: Beda.

Author
Posts
#395997

Hi

I am trying to output a div in a content template depending upon if the post body in the cpt has content.

I found this thread : https://toolset.com/forums/topic/not-display-wpv-post-body-if-empty/

And I copied and pasted the conditional into my content template:

 			[wpv-conditional if="( '[wpv-post-body view_template='None']' ne '' )"]
            	<div class="row">
                	<div>[wpv-post-body view_template='None']</div>
                </div>                    
         	[/wpv-conditional]

But this does not work. the output of wpv-post-body is not rendered, even though there is data in the wpv-post-body

Second question, I was unable to select the wpv-post-body from the conditional statment drop down, and I am also unable to find the debug information after the latest updates, so I could attach the information to this thread.

#396092

1. The Debug info has been removed upon further notice:
https://toolset.com/faq/provide-debug-information-faster-support/

2. You can not select the Post Body in the Conditional Output GUI, when you select as data "Views ShortCodes", I assume this is because it needs Custom Code, and that's why our DEV excluded it from eh GUI.
(I need to check this with the DEV though to be sure)

3. Following up, your code does not work because you can not check the Post Body this way.

You need Custom Code, which is elaborated here:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-custom-functions-in-conditions/ > Checking For Empty Post Content

You will need to follow the instructions in the DOC and then it will work as expected.

Thank you

#396138

Ok I have followed the instructions mentioned here: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-custom-functions-in-conditions/

And I have a working solution.

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