Skip Navigation

[Resolved] Order the custom field by passing parameter

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

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

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 1 reply, has 2 voices.

Last updated by Jamal 3 years, 2 months ago.

Assisted by: Jamal.

Author
Posts
#2237515

Dear Sir/Madam

I have CPT Tasks with 3 custom fields, is it possible to make a View with sorting by one of the custom fields? I want to pass an URL parameter and select the field in order.

Best regards,

Kelvin

#2237587

Hello Kelvin and thank you for contacting the Toolset support.

That's not possible out of the box. You will need custom code in order to achieve it. First, create the view without any ordering setting. Then, add a dropdown, in HTML, with the desired field labels. Then hook into the view's query filter and set the order based on the chosen field, according the WP_Query ordering arguments https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters

I hope this helps. Let me know if you have any questions.