TangibleInc / template-system

A template system for WordPress with content type loops and conditions
https://docs.loopsandlogic.com/reference/template-system/
8 stars 3 forks source link

Loop tag's field_compare attribute not working #57

Closed BenTangible closed 8 months ago

BenTangible commented 9 months ago

Hi @eliot-akira, it seems the field_compare attribute is breaking loops. I'm surprised this hasn't come up for anyone else on the forums, I just noticed it while tinkering!

I have some posts on my site with IDs 14, 23, and 16. When I do either of these, it works no problem:

<ul>
  <Loop type=post field=id field_value=14>
    <li><Field title /></li>
  </Loop>
</ul>
<ul>
  <Loop type=post field=id field_compare=is field_value=14>
    <li><Field title /></li>
  </Loop>
</ul>

However, if I try using any other comparison, my loop returns nothing:

<ul>
  <Loop type=post field=id field_compare=in field_value=14,23,16>
    <li><Field title /></li>
  </Loop>
</ul>
<ul>
  <Loop type=post field=id field_compare=starts_with field_value=1>
    <li><Field title /></li>
  </Loop>
</ul>

Seems like an oddly basic bug! Hopefully, you can pinpoint the cause.

By the way, thanks for being so on top of responses and stuff on the forum, I don't want to add more to your plate so we can handle that if you prefer, but it's nice to see you on there :)

eliot-akira commented 9 months ago

Thanks for the issue report! Indeed that's surprising, it seems like a basic thing that should be working. I'll look into it.

About the forum, you're right I've been unusually active on there - I just wanted to make sure the version 4 upgrade went smoothly. It looks like things have settled down, so I'll go back to lurking, haha. I'm more comfortable and productive working behind the scenes anyway.

(That reminds me, I read a pretty good article on the topic of field queries: Custom Fields vs. Custom Taxonomies, When to (Not) Use?.)

BenTangible commented 9 months ago

Hi @eliot-akira, I've bumped up this issue to a priority because I need comparison-based field filtering on a block I'm updating for the agency site. I'd like to move the agency site over to our new hosting platform and this is the last piece of the puzzle that's stopping me from getting there. Anything you could do to expedite this would be massively appreciated :)

BenTangible commented 9 months ago

Update: I've implemented a workaround so this is no longer urgent for the agency site and I haven't seen it reported anywhere else. Still an issue with a core piece of the language, but it's not blocking us internally anymore so I've removed the priority label.

eliot-akira commented 8 months ago

Thanks @BenTangible, this should be solved now.