Skip Navigation

[Resolved] Sort distance as a number

This support ticket is created 2 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 3 replies, has 2 voices.

Last updated by Matthew 2 years, 2 months ago.

Author
Posts
#2488113
Distance.jpg

I'm using the maps distance functionality to calculate the distance between a location entered in a search box and custom posts on my site.

Everything works, but when I display the distance in a table and try to sort it, it is sorted as a string and not a number.
How do I get this sorted as a number?

Table can be seen on this page: hidden link

Thanks!

#2488541

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I'm sorry Matthew, we don't have support for ordering by distance in tables.

The table gets generated with what appears to be a sorting control for the column, but it doesn't work, the logic required for it to function isn't hooked up.

We have an existing internal ticket about this, and I'm adding this thread to it to boost the priority, but it's quite an old ticket so it doesn't look like it will get implemented anytime soon.

I suggest you don't have orderable columns in your table, and instead set the order of the View to always be by distance.

#2488839

Hi Nigel,

Ok fair enough. I'm pretty sure I'll be able to handle sorting on the front end with another library then since it's not supported with Toolset so no problem.

I would actually really like to be able to sort by distance and haven't been able to make that work either. I'm using the Legacy Builder. I can sort by Post Title, Date, etc, but nothing for Distance. Where should I be looking?

Thanks!

#2488875

I ended up just handling this all on the front end using Datatables. Thanks for the help!