At the moment, when a User selects ‘view questions’ – it will show ALL Questions regardless if they are answered or unanswered.
example:
if you go to https://www.designwall.com/question/
you will see that the default filter is ‘ALL’ and not answered or un-answered etc.
where do i make changes to enable a different default filter?
You can use the following code in the functions.php file in your theme:
http://snippi.com/s/3xctth2
Then replace the Filter name in the line 6.
Hey Dominic – thanks for that – Although, trying to look for an alternative and avoid editing something outside the plugin code itself. I think it’s pretty silly to have to edit the theme for a dependency i would expect internal to the plugin framework and set of code. Having reviewed it the set of code and plugin, what you could do is edit inc/filter.php
under the public function prepare_archive_posts, you’re already defining a set number of Arrays – although calling for each argument to be stored in $filter, just pre-define the variable.
So, before going into the switch ( $filter ), add a $filter = ‘resolved’;
in other words, what’s in the snippi link above but within your plugin codeset.
many thanks,
At the moment, you should filter and add code outside the plugin. Will save for the plugin update.
Hi , now, one year after, ¿can we configure the default filter in a easier way?
At the moment, you only use the custom code to resolve this issue.
add_filter(‘dwqa_prepare_archive_posts’, ‘dwqa_custom_filter’, 10, 1);
function dwqa_custom_filter($query){
if(!isset( $_GET[‘filter’] ) || empty( $_GET[‘filter’] )){
// filter by status
$filter = ‘all’;
switch ( $filter ) {
case ‘open’:
$query[‘meta_query’][] = array(
‘key’ => ‘_dwqa_status’,
‘value’ => array( ‘open’, ‘re-open’ ),
‘compare’ => ‘IN’,
);
This change is correct to show all questions?
Why do you need to change the code to display all questions while defaulting of the plugin is showing all the question.
Please login or Register to submit your answer