Loop Taxonomy Comparison Issue

Hey all, I’m having an issue getting something to display properly.

I have a post type for Loan Officers (loan-officer)

And that Post Type has 2 taxonomies Licensed States (licensed-state) and Physical Location (physical-location)

I am then calling the proper taxonomies via an ACF Field for a specific state (choose_state).

I am trying to create a loop that takes the licensed-state taxonomy and compares it to the physical-location taxonomy and doesn’t display the posts that have the physical-location applied to it.

When I try to do this currently using the taxonomy_compare=not it does remove the posts if a physical-location matches the choose_state field, however it is then displaying all other posts and not just the licensed-state taxonomy term using the (choose_state) field.

I have made sure on the ACF field that the values and the slugs for both licensed-state and physical-location match.

<Loop type=loan-officer taxonomy=licensed-state terms="{Field choose_state}" taxonomy_compare=not taxonomy=physical-location terms="{Field choose_state}" orderby=title>

Anyone have any ideas why this isn’t working?

I just responded to your Facebook post and then came over to the forum and noticed you’d posted your question here too, so I figured I’d share my answer here for anyone else who might be interested. While I’m at it, I’ll highlight that this forum is generally a better place to ask template-related questions since Facebook doesn’t offer any way of formatting code. Just be sure to use backticks around your code to make it shows up right. I’ve edited your original post to make it display correctly.

It looks like someone on our team reorganized the docs about query parameters available on post loops which has obscured how to work with multiple taxonomies. Basically, your issue here is that you’ve got multiple instances of the same attribute, which isn’t syntax that L&L can understand. Just like HTML. The solution (which is the thing that’s kinda hidden on the docs) is to use taxonomy_2 and terms_2 along with taxonomy_relation to specify whether you want and or or logic for these two taxonomies. So in the end, your loop might look something like this (you’ll need to test this with your own data structure since I’m just eyeballing it without testing).

<Loop post_type=loan-officer
      taxonomy=licensed-state
      taxonomy_compare=not
      terms="{Field choose_state}"
      taxonomy_relation=and
      taxonomy_2=physical-location
      terms_2="{Field choose_state}"
      orderby=title>