Post loop with taxonomy assigned

Maybe I’m just missing something, but I try to create a post loop showing all results having ANY term in certain taxonomy.
I tried

<Loop type=post taxonomy=my_tax> AND
<Loop type=post taxonomy=my_tax taxonomy_compare=exists>

but no luck.

Any idea?

I’ve sent out the bat signal (duck signal?) to a dev to see if this is the intended behavior. Based on the fact that the taxonomy query parameter specifically says to use it with the terms attribute, I wonder if this is simply how PHP’s wp_query feature works in the first place. I can see why you’d want to use the syntax as you wrote it (I would have assumed that would work too), but it would also make sense if the terms parameter was necessary since WordPress stores post IDs alongside taxonomy terms, not taxonomies overall.

In any case, I think it’s possible to work around this pretty easily with something like this:

<List terms>
  <Loop type=taxonomy_term taxonomy=my_tax>
    <Item><Field id /></Item>
  </Loop>
</List>

<Loop type=post taxonomy=my_tax terms="{Get list=numbers}">

or this:

<Loop type=post taxonomy=my_tax terms="{Loop type=taxonomy_term taxonomy=my_tax}{Field id /},{/Loop}">

I’ll let you know when I hear back from the dev.

Thanks for the reply.
There are many work around options. :slight_smile:

As I only want to present an error message if something is empty I ended up to set a variable when there is content and to present the error message if the variable is not set. So I do not need to loop multiple times - just using the loop I run anyway.

1 Like