Skip Navigation

[Resolved] Post body in Conditional Block

This support ticket is created 4 years, 5 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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 1 reply, has 2 voices.

Last updated by Jamal 4 years, 5 months ago.

Assisted by: Jamal.

Author
Posts
#1761009

Hi,
I am using the Conditional Block to show custom fields when they are not empty.
It works with any field except when I use "Post Content (Body)".

hidden link

What I am doing wrong?

Thanks
Best

#1761203

Hello and thank you for contacting the Toolset support.

I run a test on a clean installation and I was able to reproduce the issue. I will escalate this to our 2nd Tier for a second evaluation before involving the developers.

In the meantime, I hope the following workaround will be a viable solution for you:
1. Add the following custom code to Toolset->Settings->Custom Code.

<?php
/**
 * New custom code snippet (replace this with snippet description).
 */

toolset_snippet_security_check() or die( 'Direct access is not allowed' );

// Put the code of your snippet below this comment.

function ts_is_content_empty(){
  global $post;
  if (strlen( $post->post_content ) == 0){
    return 1;
  } else {
    return 0;
  }
}

2. Register the "ts_is_content_empty" function for use in conditions in Toolset->Settings->Front-end Content->Functions inside conditional evaluations. Check this article https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/using-custom-functions-in-conditions/
3. Update your conditional block to use this function instead of the builtin "Empty" function. Check this screenshot hidden link
Then update your block accordingly.

I run my test on an online installation, you can check it closely using the following URL hidden link