Hey Paul
You don’t need to do this via query args – you can do all this via the posts
tab.
If it must be dynamic and via the query args, then its the same as when using the standard new WP_Query($args)
https://www.designsandcode.com/documentation/search-filter-pro/action-filter-reference/#Edit_Query_Arguments
So, to modify orderby
you need this part of the WP docs:
https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
Updating the S&F filter example with the example from the WP site on order:
$args = array(
'orderby' => 'title',
'order' => 'DESC'
);
$query = new WP_Query( $args );
Will update the filter like:
function filter_function_name( $query_args, $sfid ) {
//if search form ID = 225, the do something with this query
if($sfid==225)
{
//modify $query_args here before returning it
$query_args['orderby'] = 'title';
$query_args['order'] = 'DESC';
}
return $query_args;
}
add_filter( 'sf_edit_query_args', 'filter_function_name', 10, 2 );
Thanks