Hi,
right now by default the “category” param supports only single category, but please post here in the middle of next week i will be then back in the office and will be able to post here a code snippet which will allow multiple categories.
ok, I will write ypu on Wednesday, thank you
Hi,
you can add the code below in your theme functions.php file (or even better create a new WP plugin and add it there)
add_filter( "shortcode_atts_adverts_list", "adverts_list_search_by_multi_category_atts", 10, 3 );
add_filter( "adverts_list_query", "adverts_list_search_by_multi_category_param", 10, 2 );
function adverts_list_search_by_multi_category_atts( $out, $pairs, $att ) {
$out["_multicat"] = "";
if(isset($att["_multicat"])) {
$out["_multicat"] = $att["_multicat"];
}
return $out;
}
function adverts_list_search_by_multi_category_param($args, $params) {
if(!empty($params["_multicat"])) {
if(!is_array($args["tax_query"])) {
$args["tax_query"] = array();
}
$args["tax_query"][] = array(
'taxonomy' => 'advert_category',
'field' => 'term_id',
'terms' => array_map( "trim", explode( ",", $params["_multicat"])),
);
}
return $args;
}
Once you do that you can use the [adverts_list] as
[adverts_list _multicat="133,138"]
Then the [adverts_list] will show Ads which are in category with ID 133 or 138.
thank you. Now is working good
Ok great, i am marking this thread as resolved then :).
BTW. If you are finding the plugin useful i would be thankful if you could write a short one or two sentence review here https://ww.wp.xz.cn/support/view/plugin-reviews/wpadverts