• Hi there,
    I’d like to be able to share a link of a particular store on the map – is their any way of doing this when store permalinks are disabled? Is there a search string / parameter that could pass the co-ordinates and or the actual listing within the results?

    Something for example like:
    mydomain.com/?action=store_search&lat=-31.98835&lng=18.43949??

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi there Rob,

    Well, there is this old trick that I use sometimes when I want to receive a location via an URL parameter and perform a search automatically. It is just a small jQuery snippet:

    add_action( 'wp_footer', function () { ?>
    <script type='text/javascript'>
    	jQuery( window ).load(function() {
            
    		let searchParams = new URLSearchParams(window.location.search);
    
    		if (searchParams.has('location')) {
    			let location = searchParams.get('location');
    			jQuery('#wpsl-search-input').val(location);	
                jQuery('#wpsl-search-btn').trigger('click');
    		} else {
    			console.log('location not received');
    		}       
    	});
    </script>
    
    <?php } );

    With this snippet in place, you could use URLs like:

    mydomain.com/?location=London,UK

    And this would trigger a search in London.

    But this would give you a standard search, with the default search radius and max results. You could use it as an inspiration and maybe receive the search radius and the max results to tune it up to something more similar to what you want.

    So, not exactly what you are asking for. That is what permalinks are for!

    Regards,

    Thread Starter southafricanrob

    (@southafricanrob)

    Thanks for the idea – it’s a cool workaround!

    Alternatively could I use permalinks conditionally? For example only use permalinks on stores from a particular category? I have 1000’s of store listed and ideally don’t want Google indexing all stores permalink / page, which I assume will happen if I enable permalinks globally?

    I know changing the plugins core code isn’t ideal but where does you permalink logic happen?

    Thanks
    Rob

    Thread Starter southafricanrob

    (@southafricanrob)

    I managed to allow only certain stores to use permalinks like this:

    add_action ( 'template_redirect', 'custom_store_post_permalink_redirect', 1);
    function custom_store_post_permalink_redirect() {
        global $wp_query;
        //whatever condition you want to use - in this case custom store meta my_custom_field
        $conditional_var = get_post_meta( get_the_ID(), 'wpsl_my_custom_field', true );
    
        //if store has my_custom_field value less than 3 then don't enable permalink
        if (( $conditional_var < 3) && is_singular( 'wpsl_stores' ) ) {
                $url   = get_bloginfo('url');
                wp_redirect( esc_url_raw( $url ), 301 );
                exit();
        }
    }

    Basically redirects all stores where conditions aren’t met to home page. Posting here incase useful to anyone else!

    Hi there Rob!

    Sorry I didn’t have time to reply your previous post.

    Um, that code snippet is a very interesting workaround for your particular needs. I don’t know if many people would want to have permalinks conditionally enabled, but in any case there it is.

    What I don’t know is the SEO implications of this, maybe the SEO gurus don’t like this redirection to happen in some stores and not in other stores, but whatever ??

    Thanks!

    Thread Starter southafricanrob

    (@southafricanrob)

    Hi again,
    From my fairly limited SEO knowledge a 301 redirect won’t hurt SEO (so long as not included in sitemap) other than that the stores redirecting won’t have any ranking value, but wouldn’t this be the case anyway if permalinks are turned off?

    My use case is that only premium stores have their own store page. If permalinks are disabled in the WPSL settings, how are you disabling the permalink? Is it not a redirect of the post URL as I’m doing?

    Thanks!

    Hi again,

    Yes, on a second thought sure, a 301 redirect won’t hurt, and having the permalinks disabled would certainly have the same outcome when it comes to SEO rankings… It was that it just seemed weird to me that some stores do some stuff when clicked on, and some others won’t (and they will take you back to the home screen). I was also trying to look for a situation where that could be useful for me, but every website is a world on its own and it sure is totally valid in your case!

    If permalinks are disabled in the WPSL settings, the corresponding URLs just don’t exist and they will yield a 404 error, so definitely not a redirection. With permalinks disabled, those URLs are just not programmatically created in the first place.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Create a link to a particular store on the map’ is closed to new replies.