Meta Box
Support › MB Views › How to show text if containing term
Hi,
I'm trying to show/hide content based on a term via Meta Box Views. I hope you can help with this.
I wish to show content only if custom Taxonomy 'internal-tag' contains term 'allitems'.
Current code:
{% if term.internal-tag contains allitems %} {% else %} <div class="block-related"> <h4>Show this text</h4> </div> {% endif %}
Thank you for taking a look. Regards, Rod
Hi Rod,
You can use the WP function get_terms() to get all terms of a taxonomy and check if a term is exist on that array.
get_terms()
{% if 'allitems' in my_terms %}
Read more on the documentation https://developer.wordpress.org/reference/functions/get_terms/ https://docs.metabox.io/extensions/mb-views/#running-php-functions