Problem:
The customer needs to order their Custom Post Types (CPTs) by slug instead of title. For example, a film titled "The Return" with a slug of "return" should be listed under the 'R' section in their film archive. The View options do not support ordering by slug, and an attempt to use a pre_get_posts() filter to achieve this has failed.
Solution:
We suggested using the wpv_filter_query filter to change the orderby parameter. The provided custom code should be added to the theme's functions.php file. The customer needs to replace 1000 with their post view's ID and your_custom_field_slug_here with the custom field slug (name) of the Film.
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
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 | 13:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Sao_Paulo (GMT-03:00)
This topic contains 1 reply, has 2 voices.
Last updated by 7 months, 2 weeks ago.
Assisted by: Mateus Getulio.