Adjusting the Default ‘Sort By’
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?
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.
You can adjust default sort by option in AnsPress options.
I tried it and it didn’t work for me.
Dev, any follow up here? Thanks!
You want to hide sort option, right?
I think he want to be able to pre-set default sort not only for answers, but for main page (questions) as well. Haven’t thought of it, but looks like a good option.
Adjusting default sorting for questions is very basic and needed option. Please add it to the options or if it is possible create an example to do it by filters.
Yes, that’s the ‘Sort By’ Answer option. I’m speaking of the main questions page. To disable it, or just have a view all. http://pasteboard.co/1kjvwwFS.jpg