woocommerce get product categories
$terms = get_the_terms( $product_id, 'product_cat' );
foreach ($terms as $term) {
$product_cat_id[] = $term->term_id;
}
woocommerce get product categories
$terms = get_the_terms( $product_id, 'product_cat' );
foreach ($terms as $term) {
$product_cat_id[] = $term->term_id;
}
wp_query product category
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => '12',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id', //This is optional, as it defaults to 'term_id'
'terms' => 26,
'operator' => 'IN' // Possible values are 'IN', 'NOT IN', 'AND'.
),
array(
'taxonomy' => 'product_visibility',
'field' => 'slug',
'terms' => 'exclude-from-catalog', // Possibly 'exclude-from-search' too
'operator' => 'NOT IN'
)
)
);
$products = new WP_Query($args);
var_dump($products);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us