NO BUG: Display Conditions Not working on query loop

Some Conditions do not work on the Query loop.
I’m not sure if it’s MetaBox related or not.

For e.g:
i have a custom post Authors linked with Metabox relationship to Books.
Book has a metabox taxonomy of types_of_books with terms Fashion, DIY, Color books, drawing books etc…

On the Author template i have a query loop that displays all Books from the Author.
When i put a condition on the loop div to show only Fashion books, it does not work.
if i put a div inside the loop and set the condition on the inner div, then the condition works.

Is that a bug or is it how it’s suppose to work?
if i remember correctly it use to work on the Query loop itself before !

Hi Yann,
Thanks so much for your report!

Understandably, the condition does not work on the loop itself (if I understand your report correctly) because it would hide the entire loop in case of doubt - and that makes no sense. Hiding individual results within the loop does, but why are you using conditions instead of selecting a taxonomy directly in the loop?

Best regards,
timmse

Hi timmse,
Thank you for your help.
It’s a Metabox Relationship Query Loop and there’s no setting to filter by taxonomy .

Is there any way I can filter by taxonomy using the code editor in the query loop?

Many thanks,
Yann

Hey,
Sorry, but it’s not always easy to play through the query loops in your head, especially when you add relationships to the mix :exploding_head:

I may still not have fully understood the setup, but in theory you could use a nested loop. You use a normal loop to query all books in a certain category and place your relationship loop in it, which then only displays the author’s books. However, I may have completely lost the plot… :face_with_spiral_eyes:

Alternatively, use your condition approach (within the loop) :v:

i just tried that and i can’t get it to work.
No book is displayed at all when i add the relationship loop inside.
Strange, i might be doing something wrong! :thinking:

My temporary solution is to wrap the inner contents in a div and put the condition on the inner div.
Works but the empty divs are still displayed on frontend.
i managed to hide the empty divs with a class

.hide-empty-div:empty {
display:none;
}

Might not be the cleanest but saves my life for now :grinning:

1 Like