Skip Navigation

[Resolved] Sorting by article number not working

This support ticket is created 3 years, 8 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 5 replies, has 2 voices.

Last updated by Shane 3 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#1999097

Hello Toolset
We have a problem with the sorting of thze search results in our product database. Since the alphabetcial sorting didn't get us the correct results, we tried switching to sorting it by article number.

hidden link

as you can see, this is also not in the correct order. The article numbers should sort from the lowest to the highest number. Is there something wrong with our shortcode? Could you please have a look?

The password to look at the site is: "gümligen"

#1999249

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Renato,

Thank you for getting in touch.

I've enabled the private fields for your next response so that you can allow me to have admin access to check on the the issue for you.

Thanks,
Shane

#2001087

Hi Shane

I hope the access worked. Did you have a chance to look into this yet?
Thanks much and kind regards
Renato

#2001109

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Renato,

Yes I was able to access the site and check on the view for you. I need some more time on this one to check to see what I can do, however from what I can see it will be difficult to sort because none of the attributes that you are using to sort is numeric or alphabet , rather alphanumeric.

In a case like this you will need to perform a natural sort using the natsort php function below.
hidden link

The only way to get this to sort in the desired way is to write a completely custom wordpress database query so that you can control the sorting.

Thanks,
Shane

#2002001

Hi Shane.

O.K, so if I get this right it, it's not possible to do this with the Toolset View Filters but has to be custom coded? 🙁

Thanks for looking into it.

Kind regards
Renato

#2002033

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Renato,

That is correct because of the alpha numeric values. Views relies on the WordPress WP_Query function in order to sort the items and this type of sorting isn't supported by the function.

Thanks,
Shane