Skip Navigation

[Resolved] conditional output not working

This support ticket is created 4 years, 3 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by Luo Yang 4 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#1733801

Tell us what you are trying to do?
use conditional output to display custom post type custom fields.

setup:
I am using elementor
I am using elementor templates

VIEW name is "Resource Options"
my custom post type is RESOURCES
my custom fields for RESOURCES are:

Check to Display Redirect Link (checkbox, checked value of 1, not checked value of 0)
Redirect Link (string)
Check to Display Download Button (checkbox, checked value of 1, not checked value of 0)
Resource Download Link (string)

here is my conditional statement:

(IF redirect link box is checked then display the redirect link)

<p>
[wpv-conditional if="( $(wpcf-check-to-display-redirect-link) eq '1' )" debug="true"]
[types field='check-to-display-redirect-link' output='raw' show_name='true' item='$current_page'][/types]<br>
[types field='redirect-link' item='$current_page'][/types]
[/wpv-conditional]
</p>

(IF download link box is checked then display the redirect link)

<p>
[wpv-conditional if="( $(wpcf-display-download-button) eq '1' )" debug="true"]
[types field='display-download-button' output='raw' show_name='true' item='$current_page'][/types]<br>
[types field='resource-download-link' item='$current_page'][/types]
[/wpv-conditional]
</p>

problem, on this page:

hidden link
you will notice that the data is all getting displayed:

Check to Display Redirect Link: 0
redirect-educators
Check to Display Download Button: 0
download-educators

even though in the backend I do not have the boxes checked to display

on this page:
hidden link

you see i have the redirect link box checked and the download box not checked and its displaying the download link anyway

I think the issue is with the elementor template system...

this page:
hidden link

the boxes on this page seem to control all pages

#1735369

Hello,

I have checked the URL you mentioned above, there isn't wpv-conditional debug information:
hidden link

Please provide your website credentials in below private message, I need to test and debug it in a live website, thanks

#1736773

Thanks for the details, I have done below modifications in your website:
1) Edit field group "Resources":
hidden link

Change both checkbox field to options "When unchecked, don't save anything to the database" .

There is a known issue with the Checkbox fields that save “0”, see erratum:
https://toolset.com/errata/checkboxes-that-save-0-are-interpreted-as-checked-by-views/

2) Edit all three posts you mentioned above:
hidden link
hidden link
hidden link

Don't need change anything, just save them again. Test them in front-end, I can see all posts work fine according the the checkbox setting from admin side, please test again, check if it is fixed, thanks