I use simple form for send values for search inside query for wordpress , but in some cases from this simple form no all values need search , in some cases one value or 3 values , etc , i use this for the search , this search based in attributes
$args = array
(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'orderby' => $orderby,
'order' => $order,
'posts_per_page' => $per_page,
'meta_query'=> array
(
array
(
'key' => '_visibility',
'value' => array('catalog', 'visible'),
'compare' => 'IN'
)
),
'tax_query' => array
(
///
array
(
'taxonomy' => 'pa_' . $attribute,
'terms' => explode(",",$values),
'field' => 'slug',
'operator' => 'IN'
),
array
(
'taxonomy' => 'pa_colors',
'terms' => explode(",","Verdes"),
'field' => 'slug',
'operator' => 'IN'
),
///
)
);
The case it´s i need search in many moments more of 1 value , and for each new value i need put other array inside function , for example :
array
(
'taxonomy' => 'pa_colors',
'terms' => explode(",","Green"),
'field' => 'slug',
'operator' => 'IN'
),
)
By this my question is if it´s possible put conditional ( as if , etc ) for each array , i know no right this syntax i writte now , but for understand my idea :
if(isset($_POST['colors']))
{
array
(
'taxonomy' => 'pa_colors',
'terms' => explode(",","Green"),
'field' => 'slug',
'operator' => 'IN'
),
)
}
That´s my question , how i can do this , thank´s help me , and regards
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire