Adjusting the Default ‘Sort By’

Solved6.63K viewsWordPress
1

Is there a way to disable the sort by -or- set the sort by to display ALL of the questions at once rather than only the actives?

selected answer
1

Below code worked for me. By editing:

$args['sortby'] = 'voted';

you can change default sorting. The example shows sorting by votes:

<?php

add_filter( 'ap_main_questions_args', 'wpdesk_ap_question_sort' );
/**
 * If filters and sorting are not set then sort questions by votes
 *
 */
function wpdesk_ap_question_sort( $args ) {

    if ( ! isset( $args['sortby'] ) && ! isset( $_GET['ap_filter'], $_GET['ap_filter']['sort'] ) ) {
        $args['sortby'] = 'voted';
    }

    return $args;
}

However this is probably not the proper approach to do it, because even when the questions are sorted by votes by default, in the sort dropdown it still shows sorting by “active”.

Probably Rahul or other developers will be able to provide a better solution.

selected as best answer
You are viewing 1 out of 2 answers, click here to view all answers.