How to show text if containing term

Support MB Views How to show text if containing term

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #38631
    RoderickRoderick
    Participant

    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

    #38640
    Long NguyenLong Nguyen
    Moderator

    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.

    {% 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

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.