Problem:
The issue here is that the user wanted to sort her view by multiple custom fields.
Solution:
This can be done by using the custom hook below.
add_filter('wpv_filter_query', 'add_custom_fields_to_view_query', 99, 3); function add_custom_fields_to_view_query($query_args, $view_settings, $view_id ) { if ( $view_id == 16257 ){ $meta_query = array(); $meta_query[] = array('key' => 'acf_directory_sort_order'); $meta_query[] = array('key' => 'acf_shipping_city'); if ( !isset($query_args['meta_query']) ){ $query_args['meta_query'] = array(); } $query_args['meta_query'] = array_merge($meta_query, $query_args['meta_query']); add_filter('posts_orderby', 'custom_order'); } return $query_args; } function custom_order($orderby) { global $wpdb; return $wpdb->postmeta.'.meta_value ASC, mt1.meta_value ASC'; }
Where you simply need to chance the names of the custom fields in the code that you want to sort by.
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.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
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)
Este tema contiene 25 respuestas, tiene 2 mensajes.
Última actualización por hace 6 años, 8 meses.
Asistido por: Shane.