Support » Plugin: WP Store Locator » Display stores alphabetically on front end

  • Resolved texins5

    (@texins5)


    I’m using your plugin to display about 8 locations with a map. I’ve found a way to hide the search box and the starting location pin. Now I’d like to display my locations alphabetically, rather than by distance. I found this advice from a year ago, but I can’t find this file to modify, so I’m assuming this has changed. Can you please update me on how to make this change in the latest version? Thanks!

    If you open the /frontend/wpsl-ajax-functions.php, then change this

    $sql_part = ‘ ORDER BY distance’;
    Into this.

    $sql_part = ‘ ORDER BY store’;

    https://wordpress.org/plugins/wp-store-locator/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    Open the /frontend/class-frontend.php, and look on line 183 & 186 for the ORDER BY distance.

    I will add a filter to the $sql_sort in a next update, so you can modify the ordering of the search results without having to change the core code.

    Thread Starter texins5

    (@texins5)

    Here’s the section I made changes to, but it’s not working. Did I miss something?

    $sql_sort = ‘ORDER BY store ‘. $limit;
    } else {
    array_push( $placeholder_values, $this->check_store_filter( ‘radius’ ), $this->check_store_filter( ‘max_results’ ) );
    $sql_sort = ‘HAVING distance < %d ORDER BY store LIMIT 0, %d’;
    }

    Thread Starter texins5

    (@texins5)

    Here’s the website I’m trying to implement this change on:
    http://www.dfwaepa.com

    Thanks!
    Deb

    Plugin Author Tijmen Smit

    (@tijmensmit)

    Yeah, you are right, the code I posted doesn’t work anymore in the 2.x version, sorry.

    You will need to sort the returned results with the help from the wpsl_store_data filter. The field you need to sort on that contains the store name is called ‘store’, but I don’t really have time to look into how to alphabetically sort a multidimensional array at the moment.

    I will have some more time for this in the next couple of days.

    Thread Starter texins5

    (@texins5)

    Ok, good to know. If you find a fix for this, let me know. I think I can smooth things over with my client if they know this will be fixed in the near future. I really don’t want to switch to a different plugin, because I’ve tried some others and think yours is the best.

    Plugin Author Tijmen Smit

    (@tijmensmit)

    Add this code the functions.php in your theme folder, and it should sort the results by store name ( at least it does on my installation 🙂 ).

    You might have to clear the store locator transient cache before you see any changes. You can do this under settings -> tools, either enable debug mode while you test it, or clear the cache.

    Thread Starter texins5

    (@texins5)

    Thank you so much! That’s perfect!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Display stores alphabetically on front end’ is closed to new replies.