Answers.Body: <p>You can pass in a CategoryModel to the <code>relatedTo</code> parameter, so its just a matter of getting the CategoryModel you're after. Something like:</p>
  
  <pre><code>{% set category = craft.categories.id(42).first %}
  {% set entries = craft.entries.section('blog').limit(3).relatedTo(category) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-12T16:07:33.763Z
Answers.Text: There's no need to retrieve the category separately. [The `relatedTo` param](https://craftcms.com/docs/relations#the-relatedTo-param) accepts the element ID (42, in your example).
Answers.UserDisplayName: Stephen Lewis
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-12T04:45:13.600Z
Answers.LastActivityDate: 2017-02-12T04:45:13.600Z
Answers.UserDisplayName: crawf
Body: <p>How do I publish a list of three most recent entries within a 'blog' section that feature the category id '42'?</p>
  
  <p>I presently have this code:</p>
  
  <pre><code>{% for entry in craft.entries.section('blog').limit(3).find() %}
      &lt;li&gt;
          &lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;
      &lt;/li&gt;
  {% endfor %}
  </code></pre>
  
  <p>However, I am having trouble properly implementing the .relatedTo() filter within this snippet, and all of the examples that I have read reference a category title rather than id.</p>
  
Tags: <categories><relatedto>
Title: How do I publish entries with a specific category id?
ThreadText: # How do I publish entries with a specific category id?
  
  (Asked by: username_0 on 2017-02-11)
  
  How do I publish a list of three most recent entries within a 'blog' section that feature the category id '42'?
  
  I presently have this code:
  
  ```
  {% for entry in craft.entries.section('blog').limit(3).find() %}
      <li>
          <a href="{{ entry.url }}">{{ entry.title }}</a>
      </li>
  {% endfor %}
  
  ```
  
  However, I am having trouble properly implementing the .relatedTo() filter within this snippet, and all of the examples that I have read reference a category title rather than id.
  
  **Tags:** categories, relatedto
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-02-12. Score: 2 | Accepted answer
  
  You can pass in a CategoryModel to the `relatedTo` parameter, so its just a matter of getting the CategoryModel you're after. Something like:
  
  ```
  {% set category = craft.categories.id(42).first %}
  {% set entries = craft.entries.section('blog').limit(3).relatedTo(category) %}
  
  ```
  
  > **Comments:**
  > **username_2**: There's no need to retrieve the category separately. [The `relatedTo` param](https://craftcms.com/docs/relations#the-relatedTo-param) accepts the element ID (42, in your example).  
  
  ---
  
  