Help, I forgot how to do something basic.

How do I pull all the entries in posts for a specific category value (field name = countryName) within the category group called country?

And I am NOT using the template for posts or the category.

I can pull all the entries using

{% for doc in craft.entries.section('posts') %}

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

But, I forgot how to now add a second condition to pull up only those entries with the countryName (say) "United Kingdom"?

Thank you.

2 Answers 2


Is this the best way to do it?

`{% set results = craft.entries.section(posts).search('countryName:"United Kingdom"') %}

It appears to work.


{% set entries = craft.entries.section('posts').countryName('United Kingdom') %} should do the trick

EDIT: {% set results = craft.entries.section('posts').relatedTo('United Kingdom').find() %}

  • It does not. It does not cause an error. But nothing is written. And everything appears when I remove the appended `.countryName('United Kingdom'). And, I double checked the field name and I tried multiple country names.
    – Hellyar
    Commented Mar 6, 2017 at 18:40
  • Sorry, I misread. I didn't realize the country name was also a category. Would {% set results = craft.entries.section('posts').relatedTo('United Kingdom').find() %} work?
    – strandall
    Commented Mar 6, 2017 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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