Merge pull request #4632 from AdvancedStyle/master
Multiple categories in the product_category shortcode
This commit is contained in:
commit
54e7ce602f
|
@ -143,6 +143,16 @@ class WC_Shortcodes {
|
|||
// Default ordering args
|
||||
$ordering_args = WC()->query->get_catalog_ordering_args( $orderby, $order );
|
||||
|
||||
if(stristr($category,',')){
|
||||
$terms = array();
|
||||
$categories = explode(',',$category);
|
||||
foreach($categories as $c){
|
||||
$terms[] = esc_attr($c);
|
||||
}
|
||||
}else{
|
||||
$terms = array( esc_attr($category) );
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'product',
|
||||
'post_status' => 'publish',
|
||||
|
@ -160,7 +170,7 @@ class WC_Shortcodes {
|
|||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => 'product_cat',
|
||||
'terms' => array( esc_attr( $category ) ),
|
||||
'terms' => $terms,
|
||||
'field' => 'slug',
|
||||
'operator' => $operator
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue