Filtering by ACF Field

Using the new filter block for ACF field settings doesn’t appear to be possible at the moment. Am I missing something?

Hi @avunu,

If you mean using data from an ACF Field in the filter block, that’s correct. We will be adding support soon.
But you can still filter any kind of ACF Field within a Query parameter.

Hey @Louis, thanks for your followup.

Can you please elaborate what you mean by “filter any kind of ACF Field within a Query parameter”?

I have a post custom field of type “True / False” that I’d like to filter on the frontend using a corresponding checkbox filter. Is this possible at the moment?

Thanks

1 Like

Hi there @avunu,

Most definitely this should be possible if you can already do so through the Query builder.

What the filter does is just bring the data (in your case false/true) to the Query arguments.

1 Like

Okay, so please excuse my ignorance here, but I can’t figure out how to accomplish what you’re indicating.

Here’s my scenario:

I have a true/false ACF field on a custom post type configured as such:
image

Then I have a filter for my query set to manually correspond with that field:
image

On my Query itself, the only thing I could figure out to use was a meta query in the absence of a built-in ACF field filter:

I can’t get this or any obvious variations of this to work. What am I doing wrong?

Thanks!

using data from aACF Fields as filter parameters, this is definite usefully.

Sorry to be a nag @Louis, but if you have any insight on the above I’d appreciate it!

Hi @avunu,

Sorry for the wait.

This is a bit trickier than I first expected because of the way we currently can’t have one filter value modify two query parameters (Meta Value and Meta Compare would have to be modified → Meta Compare set to NOT EXIST if you wanted to query FALSE).

Please bear with me while I give this a bit more thought and see where we can go with it.

3 Likes

I got the query to work with a static filter (meta query but not filter block).

ACF true/false fields are stored as 1/0 in the database, but digits don’t seem to save at the moment when entered into the “Meta Value” field in a Quickly Meta Query dialog. This is what I finally found as a workaround:
image

I still have no success with using the filter block for this.

Yes this is a possibility, but requires you to have the post saved with the specific premium key saved as false/true. It won’t show posts that are false but haven’t had the value applied yet (if the field was created aftermath).

Filtering for this works fine on my side… What is the issue?

[Filtering by ACF Field], Heroes, when will this be release?

Hi @qiang814k,

Just to confirm that you can filter a Query using ACF as the source. What isn’t currently possible is to use ACF data to list options in the filter block.
This is being worked on.

2 Likes

thanks so much for your prompt reply, what i mean is “ACF data to list options”(i have used this by the search and filter plugin before, it’s nice and neat ), it’s nice to hear you are working on it, let’s wait for it. :muscle: :muscle:

1 Like

I’m looking forward to being able to list ACF data in the filters as well.

Right now I’m getting around it by manually inputting static options, but the downside is that you can’t hide/disable options when empty.

5 Likes

Hello guys,

I was looking into this and I found really good solution for now.
You can use WPgrid builder plugin to use their facets to filter gutenberg query and use cwicly to design your cards!!! It works like a charm. If you want I can provide wp access to my setup :slight_smile:

Here is link to my dev instalation - https://dev.cassareal.sk/nehnutelnosti/

1 Like

Hi @JohnySvitana,

That’s interesting, thanks for posting this!

But as I can see the grid is still from WP Gridbuilder. So how can you build the cards with Cwicly if I may ask?

1 Like

Hi!! Jonas.

Grid is not from wp grid builder.
Look for “loop” in wp blocks.

You can use their facets which are basicaly filters to filter any query on your site.
So you will build your card with cwicly use it with this gutenber block and than filter this with wpgb.

It works with ajax so therefore you cannot use custom cwicly query for archive pages and there is also small issue with “loade more button” not working properly with this setup.

Look at this for archive page - https://docs.wpgridbuilder.com/resources/guide-filter-archive-pages/
and this for normal query loop - https://docs.wpgridbuilder.com/resources/guide-filter-custom-queries/

Try on your own first and if you whould have any issue I can do some screen share for you or something.

1 Like

@JohnySvitana but the Cwicly Query can not be filtered with the Facets from WP Gridbuilder, right?

Will keep this possibility in mind cause the Facets from WP Gridbuilder are great!

@Jonas actually it can be filtered. You just need to apply class to the query template and if you are not on archive page you should put short code with query ID before your loop.

I totally agree their facets are amazing but builder is crap in my opinion.
But if you do not need some specialities in your cards I would use wpgb grid just because of the convenience.

@Jonas and also when you filtering cwicly query keep in mind that pagination is broken as it needs to be controled by facets and it can work but than filtering facets stop working. This is due to pagination settings in queryy itself - when in URL mode there are some defaults set up and this is preventing load more facet and pagination facet to work and when you manualy setup your query filtering stops working because of manual mode of query but in this case load more button and pagination are working.

This was the reason why I eventualy ended up with gutenberg query loop block.