Skip Navigation

[Resolved] Trouble testing a conditional for a taxonomy custom field

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

Last updated by Minesh 2 months, 2 weeks ago.

Assisted by: Minesh.

Author
Posts
#2772654
Screen Shot 2024-10-08 at 6.40.59 PM.png

(please see attached image)
I've got a view which I insert on archive pages for categories.
I've added a custom field to my categories. It's a URL field called category-resource-page-url.
I know it works because I can output it just fine outside of the conditional in this same context.

However, when I try to run a conditional to test whether or not its empty, it evaluates as false even though it's true:

[wpv-conditional if="( NOT(empty($(wpcf-category-resource-page-url))) )"]
<h4>Resource page</h4>
[wpv-taxonomy-field name="wpcf-category-resource-page-url"]
[/wpv-conditional]

Can you help me figure out how to structure this conditional to properly evaluate the custom taxonomy field wpcf-category-resource-page-url ? thanks!

#2774160

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

To check the condition for the taxonomy field, you will have to create a view and set this view to query the taxonomy where you added the taxonomy custom field "category-resource-page-url" and move the condition you have inside this taxonomy view's loop:

For example:

[wpv-conditional if="( '[types termmeta='category-resource-page-url'][/types]' ne '')"]
          <h4>Resource page</h4>
      [types termmeta='category-resource-page-url'][/types]
[/wpv-conditional]

So, the steps are:
- create the taxonomy view for your desired taxonomy
- add the conditional shortcode inside this taxonomy view's loop
- add "Query Filter" for the "Taxonomy term":

Taxonomy term filter
Taxonomy term ID is set by the shortcode attribute "terms"

- call this taxonomy view and pass taxonomy ID as view's shortcode attribute where you currently displaying the conditional shortcode.