• Hi there,

    I’m using the filter gmw_default_form_values and didn’t seem to be a way to sort on DESC. The following it’s sorting by ID but on ASC order:

    function gmw_modify_default_form( $gmw )
    {
    $gmw[“page_load_results”][“orderby”] = ‘ID’;
    $gmw[“page_load_results”][“order”] = ‘DESC’;
    return $gmw;
    }
    add_filter( ‘gmw_default_form_values’, ‘gmw_modify_default_form’, 60, 1 );

    Any help would be appreciated. Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Author Eyal Fitoussi

    (@ninjew)

    Hello @smazzoni,

    Your solution doesn’t work because the page_load_results does not make the use of the ‘order’ argument. It simply does not pass it to the search query.

    However, you could use the filter ‘gmw_pt_search_query_args’ instead. You can use this filter to modify all of the search query arguments before the query takes place.

    Try the script below:

    
    function gmw_pt_custom_orderby_query( $query_args, $form ) {
    
    	// verify that we are in page load results query.
    	if ( empty( $form['page_load_action'] ) ) {
    		return $query_args;
    	}
    
    	$query_args['orderby'] = 'ID';
    	$query_args['order']   = 'DESC';
    
    	return $query_args;
    }
    add_filter( 'gmw_pt_search_query_args', 'gmw_pt_custom_orderby_query', 99, 2 );
    

    I hope this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘Descending Sort’ is closed to new replies.