• Hi have some problem to run this code it is an brand site with woocommerce-brands plugin.
    I om trying to only show by product_tag.
    I have made a code, there work with tags but it will not work with brands.

    
    $term = get_queried_object();
    
    if ($query->is_archive()) {
                    $query->set('tax_query', array('taxonomy', 'product_brand',
                        'field', 'slug',
                        'terms', $term->slug));
                    $query->set('post_status', 'publish');
                    $query->set('posts_per_page', 40);
                    $query->set('product_tag', $teen_kids_adult);
    
                }

    Hope some can help.

    Best regards
    Morten

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Your “product_tag” query var is conflicting with the “tax_query” query var. You need to combine all taxonomy parameters into the one “tax_query” query var.

    The current “tax_query” assignment is invalid, it needs to be an array within an array. This requirement seems odd when there is only one taxonomy parameter, but it makes more sense once you add “product_tag” to the mix. See the “Multiple Taxonomy Handling” examples in the WP_Query docs page.

    Be sure $teen_kids_adult is assigned a value and it is within scope of your code.

    Are you sure the “post_type” query var is already correct? It might be another query var you need to set or modify.

    If you still have trouble after handling those issues, output the global $wp_query->request value on the template being used. This is the actual SQL used. Determine which clause in the query is causing it to fail to do what you want.

Viewing 1 replies (of 1 total)
  • The topic ‘Brand site show only by tags’ is closed to new replies.