Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Keith

Problems with acp/filtering/dropdown_args

First… how do I change my name from ‘Amy’ to ‘Keith’ here in support? :) My account has no indication of ‘Amy’ anymore.

Alright, here is the real issue. I have an ACF True/False field that determines the ‘Status’ of a Project. I turned on Filtering for this field.

By default… Admin Columns shows: All Status and false as options.
Choosing ‘false’ does nothing. I would assume it would show all records that have ‘Status’ set to False, but it doesn’t.

Either way… I decided to remove ‘false’ from the dropdown and use “Incomplete” and “Complete” instead. They show up as expected, but neither produce an results.

Here’s my code:


<?php
/* START: Changes 'Project Status' filtering choices */
function cc_change_project_status_filtering( $args, $column ) {
$column_type = 'column-acf_field';
$acf_key = 'field_59b3ee7a68104'; // Project Status field
if ( $column_type === $column->get_type() && $acf_key === $column->get_setting( 'field' )->get_value() ) {
unset( $args['options'] );
$args['options'][0] = 'Incomplete';
$args['options'][1] = 'Complete';
}
return $args;
}
add_filter( 'acp/filtering/dropdown_args', 'cc_change_project_status_filtering', 10, 2 );
/* END: Changes 'Project Status' filtering choices */
?>

For the [value] I have tried: 0, ‘0’, FALSE etc. but none worked.

Thanks for your help on this!
Keith (not Amy) :)

6 years, 7 months ago
Stefan van den Dungen Gronovius
Developer

Hi Keith,

I tried to reproduce the issue on my local environment with a default ACF Boolean Field and filtering seems to be working fine on that field.

By default, We show the following options in the dropdown.
– Show all: Default label
– False: for everything that is set to 0 or where the ACF key does not exist
– True: for everything that is not 0 (in an ACF boolean field this is value 1)

So the snippet you have should work unless you have some other hooks that can alter the query, think about a pre_get_post filter. You could have a look in your code if you can find any code where you change the (meta)query for your ACF field field_59b3ee7a68104 that could conflict with the overview here. Maybe there is a ! is_admin() missing somewhere where you only want to change the query on the frontend.

Or you could analyse the SQL query that is fired for the overview and see if anything strange is present in that query.

One last thing you could do, is to check if sorting is active on the overview. By default we hide every post that has no content unless you change this in our settings. For Boolean fields this means that if you filter on false and also sort on that column, this give no results. If you see the ‘Reset sorting’ button, try hitting that and try to filter again on the the false value.

If this does not solve your problem, please try to reach me at support@admincolumns.com.

6 years, 7 months ago

You must be logged in to reply to this topic.