Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Reobed

    (@reobed)

    Addition to that : If I make a wp page with called rotterdam and I am able to use like [adverts_list location=”rotterdam” I am also happy because the url will be
    https://loketgevondenvoorwerpen.nl/rotterdam/ as well.

    Is that possible ?

    Plugin Author Greg Winiarski

    (@gwin)

    You can have _location param in the [adverts_list] by adding the code below in your theme functions.php file

    
    add_filter( "shortcode_atts_adverts_list", "my_custom_shortcode_atts", 10, 3 );
    add_filter( "adverts_list_query", "my_custom_shortcode_param", 10, 2 );
    function my_custom_shortcode_atts( $out, $pairs, $att ) {
        $out["_location"] = "";
        if(isset($att["_location"])) {
            $out["_location"] = $att["_location"];
        }
        return $out;
    }
    function my_custom_shortcode_param($args, $params) {
        if(!empty($params["_location"])) {
            $args["tax_query"][] = array(
                'taxonomy' => 'advert_location',
                'field'    => 'term_id',
                'terms'    => $params["_location"],
            );
        }
        return $args;
    }
    

    After adding it you should be able to use the [adverts_list] as

    
    [adverts_list _location="1000"]
    

    where 1000 is an ID of the Rotterdam term.

    Thread Starter Reobed

    (@reobed)

    All right. Let me try to do so !
    Thanks !

    Thread Starter Reobed

    (@reobed)

    Works like a charm !
    You are the man.

    If you have any time left in the new release, you might want to add this be default as a short codeas it does realy work beter for SEO.
    Thanks again, you are the man !

    Plugin Author Greg Winiarski

    (@gwin)

    In the next release, MAL extension will register the “location” param (or something similar) in the [adverts_list].

    I have spent a fair bit of time reworking rewrite rules to change all the wpadverts paths to be more to my liking (and should be seo friendly), it’s in a custom theme but I’d be glad to share if you want. (make that “all” wpadverts paths for components we use, we don’t have all the modules enabled, etc.)

    FWIW we use:
    /classifieds/ top level [adverts_list] page
    /classifieds/{adverts_category}/ category archives
    /classifieds/{adverts_category}/{advert_post_title}
    /classifieds/locations/{country}/{state}/{city} hierarchical location paths

    I didn’t make the category path hierarchical, for better or worse (would be easy to do).

    Thread Starter Reobed

    (@reobed)

    Yes please share these rewrite. It might get in handy.

    Hi,
    i use [adverts_list _location=”1625″]
    as a 1625 shuould show only one location (Zlin) but it shows all.
    https://hokejman.cz/hokejovy-bazar-zlin/

    Could you help me?

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    1. do you have in your theme functions.php (or in a separate plugin) the code which allows using the “_location” param? If you do not then you will need to add it first.

    2. the quotes around 1625 might be misformatted and the WP parser might not be able to recognize the param and the value.

    If you are using classic editor then edit the page with your shortcode, in the editor click the “Text” tab and type the shortcode again from the keyboard.

    If you are using Gutenberg, then remove the shortcode text, add a Shortcode block and enter there the shortcode from the keyboard.

    Or instead of entering the shortcode from keyboard copy and paste the one below it is using correct quote characters

    
    [adverts_list _location="1625"]
    
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘location url adjustment’ is closed to new replies.