Simple filter based on a custom field

Hi,

I have another thread open for this but posting again for a solution that isn’t necessarily like the one I am having trouble with.

I have a new CPT - Research Papers. I can list them all on a page using template (added as a short code). The template features a Query Loop for that CPT. Easy.

I want to create another page that only lists Research Papers that have a ‘Highlight’ custom field set to True. I’ve tried creating this with Pods and ACF but had luck using a Conditions like this one:

image

I’ve checked and rechecked the value and tried other ways.

If I use a tag to achieve the same in the Query Loop it works, but I want to use a custom field.

Is this at all possible? Perhaps using a Meta Query?

Thanks.

Since it seems like you want to fetch a list of posts using a query loop a meta query should be your way to go.

CleanShot 2023-02-28 at 10.51.35

Depending on the plugin you are using for your custom fields the value you are comparing to might have to be different. In my case I am using ACF and 1 works as expected. If you are having problems you could try to compare against true or True.

Hi - thanks, I now know how this works!

Both ‘1’ and ‘True’ don’t work.

I got it working in context. So, on a post of the same CPT and using the condition on an element.

That must be the issue - I want to display a template on a Page. The shortcode referring to the template works when I display all items but not the condition or meta query.

FYI - To get this working I created a new Category (via Pods) and used the Taxonomy part of the Query loop.

I would have preferred to use a custom field but this will have to do.

I too am struggling with this. I have a field that is basically “0 or 1”, or I set it as “Yes or No” and so on. I have tried comparing wit not setting, Equal, Numeric, CHAR - anything that would make sense for the character returned. I have tried pretty much all I can think of in reference to the image in the post above in this thread.

Wen it does work, I only get one post returned even though I have some that should and some that should not be returned.

I definitely want to use the value of a field for this query parameter and not some Category or Tag.

I have tested with more than one WordPress instance, trying a minimalist instance besides the current project. I have tested with Bricks 1.7.3 and 1.8 Beta 2

Hey @jmcbade,

if you can provide me with some temporary credentials to your site I’m happy to have a look.

Best,

André

same problem here. i found a workaround using condition but it’s not perfect.

Hey @g97iulio,

if you can provide me with some more information about your setup and what you’re trying to achieve I’m happy to help.

Best,

André

It’s really simple acf true/false field called coaching , I set meta name and true or false (or 0 and 1). It doesn’t work .

Hey @g97iulio,

could you please show a screenshot of your meta query setup in the builder? And also of your custom field‘s setup in the ACF backend?

Without this it’s just guessing.

Thanks,

André


that’s it

Hey @g97iulio,

instead of {acf_coaching} just put a 1 into the valore meta field if you only want to query posts with the coaching field set to true.

Best,

André