Skip Navigation

[Resolved] Conditions to hide a link

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

Problem:
Conditions to hide a link

Solution:
you can use [wpv-conditional] shortcode with Types custom fields shortcodes to compare the Types custom fields values and display the content conditionally:

You can find the proposed solution in this case with the following reply:
https://toolset.com/forums/topic/conditions-to-hide-a-link/#post-1344853

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

This support ticket is created 5 years, 1 month 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
- 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)

This topic contains 4 replies, has 2 voices.

Last updated by deepS 5 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#1343927

Hi, I have a job website with 'Job' post types. It contains various custom fields. There are two custom fields with url links. It often happens that both of my url links in the same post type is same. Hence I want to hide the second url link where the two url links are same. How can I achieve it through conditional output? Please help.

#1344031

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Can you please tell me how you added both of those fields that is having links?

Normally, you can use Types shortcode with conditional shortcode:

For example:

[wpv-conditional if="( '[types field='your-field-1'][/types]' eq '[types field='your-field-2'][/types]' )"]
[types field='your-field-1'][/types]
[/wpv-conditional]

[wpv-conditional if="( '[types field='your-field-1'][/types]' ne '[types field='your-field-2'][/types]' )"]
Field 1: [types field='your-field-1'][/types]
Field 2: [types field='your-field-2'][/types]
[/wpv-conditional]

More info:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

#1344253

See, in my job post I usually put two links at the bottom of the post- one for 'Job notification' and the other for 'Apply Online' and both are compulsory fields.
There are certain circumstances where the hiring company doesn't provide online application facility and since these are compulsory fields we put the 'Detailed Notification' link in the 'Apply Online' so that it doesn't show validation error while saving the Job post.
I don't know whether this validation can be made optional from post to post. But I found that a condition logic by matching the values in the custom URL fields would help me to hide the duplicate link.
Here I am giving you examples:
Example 1: This link has two buttons at the bottom of the post with two different urls (hidden link) This is OK.

Example 2: This link has two buttons at the bottom of the post with one urls (hidden link). I want to remove the 'Apply Online' button.

The following codes are in use at present.
For Detailed Notification:

[wpv-conditional if="( $(wpcf-last-date-of-application) gte 'TODAY()')"]
<div id="button-1">[types field='detailed-notification-link' title='Detailed Notification' target='_blank'][/types]</div>
[/wpv-conditional]

For Apply Online:

[wpv-conditional if="( $(wpcf-last-date-of-application) gte 'TODAY()' ) AND ( $(wpcf-walk-in-interview) ne '1' )"]
<div id="button-2">[types field='apply' title='Apply Now' target='_blank'][/types]</div>
[/wpv-conditional]

Hope I can make you understand my point. Thank you.

#1344853

Minesh
Supporter

Languages: English (English )

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

Ok - what if you just try to remove the following conditional statement:

[wpv-conditional if="( $(wpcf-last-date-of-application) gte 'TODAY()' ) AND ( $(wpcf-walk-in-interview) ne '1' ) "]
<div id="button-2">[types field='apply' title='Apply Now' target='_blank'][/types]</div>
[/wpv-conditional]

And replace that with the conditional statement as given under and try to resolve your issue.

[wpv-conditional if="( $(wpcf-last-date-of-application) gte 'TODAY()' ) AND ( $(wpcf-walk-in-interview) ne '1' )  AND  ( '[types field='detailed-notification-link' output='raw'][/types]' ne '[types field='apply' output='raw'][/types]' )"]
<div id="button-2">[types field='apply' title='Apply Now' target='_blank'][/types]</div>
[/wpv-conditional]
#1345113

My issue is resolved now. Thank you!