Skip Navigation

[Resolved] PHP to see if post been been assigned custom taxonomy value

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

Our next available supporter will start replying to tickets in about 7.11 hours from now. Thank you for your understanding.

This topic contains 2 replies, has 2 voices.

Last updated by Renier 6 years, 1 month ago.

Author
Posts
#1121565

Tell us what you are trying to do? I've assigned a custom taxonomy to posts. Some posts have custom taxonomy 'values' assigned to them, others don't. I want to use this criteria in PHP as a conditional. e.g. has custom taxonomy value(s) assigned do x, else do y (or vice versa). I just need to be able to establish the conditional (e.g. yes or no).

Is there any documentation that you are following? No

Is there a similar example that we can see? No

What is the link to your site? na.

#1121915

Toolset Support cannot help with this question since this is about WordPress and PHP - not related to whether the Post Type is made with Toolset or not.

In any case, you will need to use the WordPress Codex to find the right API to use, and the PHP Codex to find the right syntax to build the condition.
I suggest to use this Function of WordPress:
https://codex.wordpress.org/Function_Reference/has_term

In Toolset, you could do that in much less time and less effort, using an HTML conditional, that listens to the Posts Terms.
That, we explain here:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/
You would then likely do this:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/#specific

That is what we recommend when you use Toolset.

#1121929

Thank you Beda ; )