php – WP_Query – How to query all of post types categories
I added a custom taxonomy to woocommerce’s
products post type. The custom taxonomy is called
Brands and is simply used to select the brand of the product.
I am using
wp_query to query all of the brands so that I may click them and get all of the products that associate. I just cant figure out how to query all of the brands for a given post type.
Here is my attempted query which isnt returning anything:
$brands = array( 'post_type' => 'product', 'posts_per_page' => -1, 'tax_query' => array( array( 'taxonomy' => 'brands', 'field' => 'name', ), ), ); $query = new WP_Query( $brands );