Support » Plugin: WPAdverts - Classifieds Plugin » [adverts_list] for specific country

  • Resolved kowalski

    (@jankowalski)


    how do i add location parameter to [adverts_list] shortcode?
    i need to display latest ads for given country.

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

    (@gwin)

    Hi, the [adverts_list] does not support location parameter i am afraid.

    i have order premium plugin custom fields and Maps & Location, with all those paid addons i still can not do this? Any hint how to filter it with php?

    • This reply was modified 1 year, 8 months ago by  kowalski.

    Hello everyone, I’m also interested in this feature. Did Kowalski solve the problem?

    Plugin Author Greg Winiarski

    (@gwin)

    With some custom programming it is possible to do this, first register a “country” param in the [adverts_list]

    
    add_filter( "shortcode_atts_adverts_list", "register_country_param", 10, 3 );
    function register_country_param( $out, $pairs, $atts ) {
        $out["country"] = null;
        if(isset($atts["country"])) {
            $out["country"] = $atts["country"];
        }
        return $out;
    }
    

    Then you can use the param “country” in the search using adverts_list_query filter

    
    add_filter( "adverts_list_query", "search_by_country_param", 10, 2 );
    function search_by_country_param( $args, $params ) {
        // do something with $params["country"] here ..
        return $args;
    }
    

    How to customize the search_by_country_param function depends on how you are storing the country?

    Once you have the function modified you can use the [adverts_list] as

    
    [adverts_list country="USA"]
    
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[adverts_list] for specific country’ is closed to new replies.