1

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') %}
--OR--

{% 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.

1

Is this the best way to do it?

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

It appears to work.

| improve this answer | |
0

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

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

| improve this answer | |
  • 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 Mar 6 '17 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 Mar 6 '17 at 19:44

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.