TangibleInc / template-system

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

Unable to filter posts by current taxonomy term on archive #110

Closed BenTangible closed 4 months ago

BenTangible commented 5 months ago

This forum user reported some issues working with the post loop query parameters taxonomy=current terms=current on a taxonomy term archive. I've tested this myself and this feature doesn't seem to work as described in the documentation:

taxonomy - Include by taxonomy ID, slug, or "current" for taxonomy archive. Use with "term" and "taxonomy_compare" attributes.

To replicate/troubleshoot this, I've created the following working layout:

<Loop field=archive_term>
    <Set term_name><Field name /></Set>
</Loop>

<h2><Get term_name /></h2>

<ol>
  <Loop type="post" taxonomy="category" terms="{Get term_name}">
    <li>
      <strong><Field title /></strong>: <Field excerpt auto="true" words="35" />
    </li>
  </Loop>
</ol>

To narrow down the issue, I've chosen to only display this layout on the "category" taxonomy term archives. image

This outputs what I'd expect when I navigate to my customizable-real-time-access taxonomy term archive:

customizable-real-time-access

1. Distributed coherent pricingstructure: Deleniti debitis iure quas. Aut autem iusto ullam atque veniam nulla recusandae nesciunt. Sit iste facilis ex qui voluptas. Voluptas accusantium quia atque voluptatem est recusandae in. Ut id eius exercitationem rerum possimus. Pariatur repudiandae 2. Enhanced responsive artificialintelligence: Et numquam et unde quo. Quasi perspiciatis autem fuga quisquam odio facilis exercitationem. Vel rem laborum nisi doloremque explicabo quasi illo. Illo vel qui eos aut quas ullam. Enim aut quidem voluptatum. Exercitationem rerum possimus ...

However, if I change my loop to either taxonomy="current" terms="{Get term_name}", taxonomy="category" terms="current", or taxonomy="current" terms="current", my loop returns no results in all three cases. The goal here would be to make sure that our layout could work on a taxonomy term archive in any taxonomy by using the current taxonomy and term, but that seems to be broken at the moment.

eliot-akira commented 5 months ago

Thanks, very helpful! Will look into solving it.

eliot-akira commented 4 months ago

Solved in https://github.com/TangibleInc/template-system/commit/fe5a96bff1ec9e6630455450bc6f9c690c5f19fe.

Thanks for the issue description of what works and doesn't work. It helped me create corresponding test cases (taxonomy=current terms="{Get term_name}", taxonomy=category terms=current, and taxonomy=current terms=current) to confirm the solution.