2

I have two categories, Annual Reviews and Publications. I want to get all entries from these and paginate them.

The code I am using is fine for one category - both work individually, but as soon as the criteria contains two categories i get zero results no errors. I have tried using 'one()' on the initial categories as I only want category returned. What am I missing? (using Craft Pro 3.1.31)

{% set publications = craft.categories.group('resources').slug('publications') %}
{% set annualreviews = craft.categories.group('resources').slug('annualreviews') %}

{% set entries = craft.entries({
section: 'resources',
relatedTo: [
'and',
{ targetElement: publications },
{ targetElement: annualreviews }
]
}).limit('10').orderBy('title') %}

{% paginate entries as pageInfo, pageEntries %}
  • 1
    Are you sure you're wanting 'and'? Or are you meaning "get all entries that have a publications or annualreviews category? – Brad Bell Jun 25 at 22:11
  • OK resolved now - client slug mis-spelling! thx – joomkit Jun 27 at 11:15
1

OK resolved now - client slug mis-spelling! thx

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.