Filtering the loop based on one custom field value OR another

Hi guys,

Probably a simple one but I can’t seem to work it out from the docs, I have a loop

 <If loop exists type="wcrm_ticket_activity" custom_field=wcrm_tickets_activity_ticketid custom_field_value="{Field id}" custom_field_2=wcrm_ticket_category custom_field_value_2="update" orderby=date order=desc>

I also want to filter by ‘audit’ as well as by custom_field_value_2=“update”

I feel it is going to use the any_is operator but can’t find the documentation.

Thanks in advance, I’ve been scratching my head too long on this.

Tom

Great question, I’m genuinely surprised that I don’t think this use case has actually come up, there doesn’t seem like an easy way to achieve this. I think this is probably just a limitation of filtering with query parameters where you can’t get fancy with logic. You can filter your query based on up to three custom field values using query parameters like custom_field_value_2 and custom_field_value_3, but it doesn’t seem like that gives you a way to say “show me results that have this value OR this value OR this value.”

When you’re filtering a loop based on multiple taxonomy terms, there’s a parameter called taxonomy_relation that you can set to and or or, but it doesn’t seem like there’s an equivalent like custom_field_relation to achieve what you’re trying to do here. I’ll pass that along as a feature request. If that’s not possible, I’m sure we should at least be able to set up a field_relation attribute for the loop tag. Maybe both.

I think the current solution to this would involve first stacking several If statements (maybe using a logic variable since that might be more compact) while setting any=true. Then if that logic variable is true, you could just create a basic type=wcrm_ticket_activity loop and then within the loop, filter it based on multiple conditions (again, maybe through another logic variable).

This seems oddly hacky though, so I’ll pass this by someone more experienced on the team to see if I’m just not caffeinated enough yet and I’m missing something obvious. If not, I’ll be sure to create a feature request since this is definitely the kind of thing that L&L should be able to accomplish more easily.

Thanks very much @benjamin , I did find it rather odd, my solution for the time being was to add a secondary category ACF as I was trying to display all with ‘update’ which included an ‘audit’ then on a different tab only an ‘audit’ which worked with 2 categories but it would definitely be nice to be able to use and OR statement of some kind in the future.

Thanks

Tom

1 Like

Any news here? Is it planed to implement a custom field relation?

Hey @PolarRacing, the short answer is that while it’s planned, we haven’t had the chance to start pursuing implementation yet.

If you’re interested, the longer answer is that our priority right now is really to address the backlog of bug reports we’ve received since that’s stopping some people from using L&L properly in the first place. We’ve also recently beefed up our efforts on testing so that future releases become more and more likely to be entirely bug-free. The next priority that’s happening in parallel to the bug fixing is that we have a handful of features we need to implement before we can release premium versions of Loops & Logic and Tangible Blocks. Until we get to the point where we’re generating income from the plugin(s), the main source of funding for the project is coming from our own agency’s client projects (L&L was built purely as a development tool for our own projects and wasn’t initially intended for release in its current form). A lot of that work is behind-the-scenes architecture stuff, so progress is being made there even if it’s not visible in the plugin itself (yet). So I’d say that since this feature request is something that feels like it should naturally be part of the product, I expect that we’ll get around to it once bugs and features that are currently preventing us from launching a paid version are out of the way. I hope that helps explain how we’re prioritizing feature requests like these alongside other parts of the plugin.

No issue for me. I know how prioritizing works in development.

It would be a cool feature, but up to know I have been able to work around the limitations. :slight_smile:

1 Like