Answers.Body: <p>You want to use the <code>relatedTo</code> filter. See the docs here: <a href="https://craftcms.com/support/entries-related-to-category" rel="nofollow noreferrer">https://craftcms.com/support/entries-related-to-category</a> where <code>category</code> is your last URL segment (eg red).</p>
  
  <p>Just a quick addition... if your category URL for the category group matches what you've used above <code>mysite/colors/red</code> and you are using the category template for that group then you will have a <code>category</code> variable already to use in the <code>relatedTo</code> filter.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-18T12:25:34.150Z
Answers.Text: That worked. I guess I was overthinking it. Thanks Mike
Answers.UserDisplayName: Ricardo Henriquez
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-18T02:40:42.223Z
Answers.LastActivityDate: 2017-07-18T02:46:08.903Z
Answers.LastEditDate: 2017-07-18T02:46:08.903Z
Answers.UserDisplayName: Mike
Body: <p>I'm sorry If this has been answered before, but I couldn't find any answer that would work for me. Maybe I'm just treating category fields the wrong way and I should be trying to do this with tags.</p>
  
  <p>Basically, I created a category group called <strong>colors</strong>. I also have several categories like <strong>green</strong>, <strong>blue</strong>, <strong>red</strong>...
  I assigned URLs that look like <code>mysite/colors/red</code>, <code>mysite/colors/blue</code>.</p>
  
  <p>All of the colors point to the same template <code>colors/index.html</code></p>
  
  <p>How can I display only the entries in <code>craft.entries.section('news')</code> that are in the "red" color category when I visit <code>mysite/colors/red</code>?</p>
  
  <p>Thanks in advance.</p>
  
Tags: <templating><categories>
Title: Display entries related to Category Field
ThreadText: # Display entries related to Category Field
  
  (Asked by: username_0 on 2017-07-18)
  
  I'm sorry If this has been answered before, but I couldn't find any answer that would work for me. Maybe I'm just treating category fields the wrong way and I should be trying to do this with tags.
  
  Basically, I created a category group called **colors**. I also have several categories like **green**, **blue**, **red**...
  I assigned URLs that look like `mysite/colors/red`, `mysite/colors/blue`.
  
  All of the colors point to the same template `colors/index.html`
  
  How can I display only the entries in `craft.entries.section('news')` that are in the "red" color category when I visit `mysite/colors/red`?
  
  Thanks in advance.
  
  **Tags:** templating, categories
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-07-18. Score: 3 | Accepted answer
  
  You want to use the `relatedTo` filter. See the docs here: <https://craftcms.com/support/entries-related-to-category> where `category` is your last URL segment (eg red).
  
  Just a quick addition... if your category URL for the category group matches what you've used above `mysite/colors/red` and you are using the category template for that group then you will have a `category` variable already to use in the `relatedTo` filter.
  
  > **Comments:**
  > **username_0**: That worked. I guess I was overthinking it. Thanks username_1  
  
  ---
  
  