i have a woocomemce site and the products have a "manufacturer" attribute.
when i get the terms for a single product :
$terms= get_the_terms($product->id,"pa_manufacturer");
i get :
Array ( [230] => stdClass Object ( [term_id] => 230 [name] => Dadawan [slug] => dadawan [term_group] => 0 [term_taxonomy_id] => 230 [taxonomy] => pa_manufacturer [description] => [parent] => 0 [count] => 4 [object_id] => 2905 ) )
Can i do a loop WP_query only with that term_id to get products with the same manufacturer? How can i get only the products with that specific term_id?
here is my test, but not working...
$args = array(
'post_type' => 'product',
'term_id' => 230 ,
'posts_per_page' => 2,
'orderby' => $orderby
);
$loop = new WP_Query( $args );
// Do stuff here to display your products
Any help appreciated, thanks.
Your problem is in your query. Term_id is not available argument for WP_Query. Here is a list of available arguments. I got the list from http://phporlando.com/wp_query-argument-list/
attachment attachment_id author author_name cat category__and category__in category__not_in category_name comments_popup day error feed hour minute monthnum name order orderby page_id page paged pagename post__in post__not_in post_status post_type preview robots sentence second static subpost subpost_id tag__and tag__in tag__not_in tag_id tag_slug__and tag_slug__in tag taxonomy - (pre 3.1) tb term - (pre 3.1) w withcomments withoutcomments year Pre WP 3.1 meta_key meta_value Since WP 3.1 fields meta_query tax_query