- This topic has 14 replies, 3 voices, and was last updated 11 years, 4 months ago by .
These forums are now closed and remain for historical purposes.
None of the content applies to the new version 3. For support, get in touch via our contact form.
Forums › Forums › Search & Filter Pro › Sorting of results of custom post type / ACF
Tagged: acf, custom post types, sorting
Got it ๐
function order_results_default( $query )
{
global $sf_form_data;
global $wp_query;
if ( $sf_form_data->is_valid_form() && $query->is_main_query() && !is_admin())
{
if(!isset($wp_query->query['sort_order']))
{
$query->set('orderby', 'race_date');
$query->set('meta_key', 'race_date');
$query->set('order', 'DESC');
}
}
}
add_action( 'pre_get_posts', 'order_results_default', 21 );
Let me know if that works ๐
Yup definitely needs to be added to the admin UI ๐