Skip Navigation

[Resolved] conditional output not working as expected

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

Problem:
How to display conditional output based on taxonomy term

Solution:
You should use [wpv-conditional] shortcode to display conditional output based on taxonomy term.

You can find proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/conditional-output-not-working-as-expected/#post-696478

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/#specific

This support ticket is created 6 years, 7 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by troyC 6 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#696271

I've tried adding the following code to my page

<h1>TESTING CONDITIONAL IF</h1>
{!{wpv-conditional if='( has_term() eq 'ventilatoren' )'}!}
<h1>TESTING VENTILATOREN TERM</h1>
{!{wpv-view name='artikel-specificaties'}!}
{!{/wpv-conditional}!}

+

{!{wpv-conditional if='( $(wpcf-artikelnummer) eq '22' )'}!}
<h1>MY ARTICLE NUMBER</h1>
{!{/wpv-conditional}!}

Link to a page where the issue can be seen:
hidden link

I expected to see:

Since "22" is filled in the articl-number-field and the term "ventilatoren" is checked i expect to see the content inside the conditional

SCREENSHOT: hidden link
-------

Extra question which is related to what im asking above is:

I've also tried to add simuluar code to a woocommerce tab. Is it possible to add the following code to woocommerce tabs ?

1. The following code does not work at all. It displays this code (see screenshot)

{!{wpv-conditional if='( has_term() eq 'ventilatoren' )'}!}
<h1>TESTING VENTILATOREN TERM</h1>
{!{wpv-view name='artikel-specificaties'}!}
{!{/wpv-conditional}!}

2. The following code does not work at all. It displays nothing
[wpv-conditional if='( has_term() eq 'ventilatoren' )']
<h1>TESTING VENTILATOREN TERM</h1>
[wpv-view name='artikel-specificaties']
[/wpv-conditional]

#696478

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I see that you are using wrong syntax to check taxonomy terms conditionally.

For example:

[wpv-conditional if="( has_term('Chinese', 'foreign-language', null) eq '1' )" ]
 
 <p class="special">This consultant speaks Chinese!</p>
 
[/wpv-conditional]

where:
Replace 'foreign-language' with your original taxonomy slug.

Please do not forget to register the has_term function at:
=> Toolset => Settings => Front-end Content tab => Functions inside conditional evaluations

More info:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/#specific

Regarding your 2nd issue to check "wpcf-artikelnummer " with condition I need to check on your install whats going wrong there.

#696951

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Glad to know that you are able to display conditional output using taxonomy terms.

No - I do not have any idea why its not working with "WooCommerce Tag Manager Plugin". You may create a new ticket and share all required information and we are happy to help you further and we will try to check why its not working with the said plugin.

This will help other users searching on the forum. Thank you for understanding.

#696983

Thanks!