Filter tag and category

Support MB Views Filter tag and categoryResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38465
    JamesJames
    Participant

    Hi i'm new with your templating, I want to show the post of these tag (cooking) and terms(Active)

    ISSUE #1: Get post tag "cooking" and terms of "active")

    {% set args = { post_type: "brand", posts_per_page: 4, tag: "cooking", tax_query: [ { taxonomy: 'brand-category', field: 'slug', terms: 'Active' } ] } %}
    				
    {% set posts = mb.get_posts( args ) %}
    {% for post in posts %}	
    
    {% endfor %}

    ISSUE #2: I want to get post of these two categories "Active" and "Excited"

    {% set args = { post_type: "brand", posts_per_page: 4, tax_query: [ { taxonomy: 'brand-category', field: 'slug', terms: 'Active' }, { taxonomy: 'brand-category', field: 'slug', terms: 'Excited' } ] } %}
    				
    {% set posts = mb.get_posts( args ) %}
    {% for post in posts %}	
    
    {% endfor %}

    Thank you

    #38473
    Long NguyenLong Nguyen
    Moderator

    Hi Kirb,

    You can refer to this topic to know how to query posts by multiple taxonomies https://support.metabox.io/topic/querying-terms-from-multiple-taxonomies/#post-36948

    The post tag (default of WordPress) is also a taxonomy with the slug post_tag, you can add this to the argument.

    #38475
    JamesJames
    Participant

    Wow! Great! Thanks soo much 🙂

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