Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    we do not have such function in the [adverts_list] by default, but you can add the code below in your theme functions.php file or create a new blank WP plugin and paste 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;
    }
    

    then you should be able to use the [adverts_list] like this

    
    [adverts_list columns="3" posts_per_page="40" _multicate="165,166,167"]
    

    where 165,166,167 are the IDs of categories.

    Thread Starter peacefuladrenaline

    (@peacefuladrenaline)

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple categories on adverts_list or single URL’ is closed to new replies.