Hi there
I have a checkboxes custom field titled Business Type. The checkboxes include Accommodation Provider, Retailer and Service Provider.
I am trying to: use conditional output in my content template to only show accommodation content when the Accommodation Provider checkbox is ticked.
I have tried the following but nothing appears in any category:
[wpv-conditional if="('[types field=‘business-type’ separator=''][/types]' eq ‘Accommodation Provider’)"]accomm content[/wpv-conditional]
[wpv-conditional if="('[types field=‘wpcf-business-type’ separator=''][/types]' eq ‘Accommodation Provider’)"]accomm content[/wpv-conditional]
[wpv-conditional if="( $(wpcf-business-type) eq 'Accommodation Provider' )"]accomm content[/wpv-conditional]
I've read through a lot of documentation but can't figure out where I'm going wrong, any help would be appreciated.
Thanks
Dear John,
Since the Types custom checkboxes field stores value in a serized array, it is not possible to use wpv-conditional shortcode to do what you want. I suggest you use Types shortcode, like this:
[types field="business-type" option="0" state="checked"]Accomm Content is checked[/types]
[types field="business-type" option="1" state="checked"]Retailer is checked[/types]
[types field="business-type" option="0" state="checked"]Service Provider is checked[/types]
More help:
https://toolset.com/documentation/customizing-sites-using-php/functions/#checkboxes
Many thanks, that works great.
Another question - can the same be done with a custom hierarchical taxonomy? if so, what would the shortcode look like?
Thanks.
To compare with terms of custom taxonomy, please try with [wpv-conditional] shortcode using wordpress function has_term(), for example:
[wpv-conditional if="( has_term('your-term-slug', 'post_tag', null) eq '1' )"]
This post has a Tag named Sedo
[/wpv-conditional]
More help:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
section "Data origin"
http://codex.wordpress.org/Function_Reference/has_term