2017-12-05 11 views

Antwort

0

dieses Beispiel,

26 eine Kategorie mit ID So gegeben, ist der folgende Code zurückkehren würde es Produkte (WooCommerce 3+):

$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);

0

Versuchen tax_query

$args = array(
    'post_type'    => 'product', 
    'post_status'   => 'publish', 
    'ignore_sticky_posts' => 1, 
    'posts_per_page'  => '12', 
    'tax_query'    => array(
     array(
      'taxonomy' => 'product_category', 
      'field'  => 'term_id', 
      'terms'  => array('40'), 
      'operator' => 'IN', 
     ) 
    ) 
); 

$loop = new WP_Query($args); 

https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

0

Versuchen Sie dies,

<?php 
    $args  = array('post_type' => 'product', 'post_status' => 'publish','category' => 34, 'ignore_sticky_posts' => 1, 'posts_per_page' => '12',); 
    $products = get_posts($args); 
?> 

Hoffe, das wird dir helfen. für mehr info.

-1

I suggest used >> wc_get_product_terms ($ vars -> ID, 'pa_brand_category')

bitte überprüfen Sie dies Screenshot >>http://prntscr.com/hjawu5

Verwandte Themen