Merge pull request #4632 from AdvancedStyle/master

Multiple categories in the product_category shortcode
This commit is contained in:
Mike Jolley 2014-07-31 07:05:37 +01:00
commit 54e7ce602f
1 changed files with 11 additions and 1 deletions

View File

@ -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
)