Kind of hard to explain but here's an example:

{{entries.all()|length}} {# outputs 88 #}

{% set hasTopic = entries.search('dataTable_topic:*').all() %}
{{entries|length}} {# outputs 7 #}

How can I keep entries the same below the search variable.

1 Answer 1


This is because of the way Element queries are in Craft 3.

In Craft 2, each time you called a setter method (search() here) it would clone your ElementCriteriaModel, use that value on the clone and return the cloned object leaving the original alone.

In Craft 3, when you call a setter method, it gets set on the current element query.

So if I understood correctly, you should use clone (docs):

{% set entries = craft.entries().section('yourSection') %}

{% set hasTopic = clone(entries).search('dataTable_topic:*').all() %}
{{entries|length}} | {{ hasTopic|length }}
  • Thank you! That was it
    – Kenyon
    Feb 14, 2020 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.