Answers.Body: <p>This can be accomplished using Craft's <a href="http://buildwithcraft.com/docs/relations" rel="nofollow">Relations</a>.</p>
  
  <p><em>My example code assumes you know the blog categories slug, and that you are pulling posts from a single category.</em></p>
  
  <p>First, you'll have to get a reference to the <a href="http://buildwithcraft.com/docs/templating/craft.categories" rel="nofollow">category ElementCriteriaModel</a> object pointing to the category of the blog post.</p>
  
  <pre><code>{% set category = craft.categories.slug('your-category-slug').first() %}
  </code></pre>
  
  <p>With a reference to the category model, you'll be able to find related entries.</p>
  
  <pre><code>{% for post in craft.entries.section('blog').relatedTo({targetElement: category}) %}
      {% if post.id != entry.id %}
          &lt;div class="related-entry"&gt;
              &lt;h2&gt;{{ post.title }}&lt;/h2&gt;
              {{ post.body }}
          &lt;/div&gt;
      {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>The if statement makes sure you aren't including the current post with the related posts.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T10:42:43.843Z
Answers.Text: It is also probably worth throwing an if statement in the loop so you don't display the original entry as a related entry.
Answers.UserDisplayName: Andris Sevcenko
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T16:53:03.953Z
Answers.Text: Yeah, great call. I included that in the answer.
Answers.UserDisplayName: Coppa
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T06:42:54.967Z
Answers.LastActivityDate: 2014-06-26T16:52:14.787Z
Answers.LastEditDate: 2014-06-26T16:52:14.787Z
Answers.UserDisplayName: Coppa
Answers.Body: <p>This can be done quite easily as follows, assuming that you are on an entry page so <code>entry</code> is a variable in your template and your category field is called <code>categories</code>.</p>
  
  <pre class="lang-twig prettyprint-override"><code>{% for relatedEntry in craft.entries({
      section: 'blog',
      relatedTo: entry.categories,
      id: 'not ' ~ entry.id
  }) %}
      &lt;a href="{{ relatedEntry.url }}"&gt;{{ relatedEntry.title }}&lt;/a&gt;
  {% endfor %}
  </code></pre>
  
  <p>I am passing an object into the ElementCriteriaModel for clarity above but you could just as easily do it by chaining parameters onto the ElementCriteriaModel as follows, it's just a matter of preference.</p>
  
  <pre class="lang-twig prettyprint-override"><code>{% for relatedEntry in craft.entries.section('blog').relatedTo(entry.categories).id('not ' ~ entry.id) %}
      &lt;a href="{{ relatedEntry.url }}"&gt;{{ relatedEntry.title }}&lt;/a&gt;
  {% endfor %}
  </code></pre>
  
  <p>See <a href="http://buildwithcraft.com/docs/relations#the-relatedTo-param" rel="nofollow">the relatedTo param</a> in the docs to understand the magic.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T23:47:34.677Z
Answers.Text: Thanks guys! :) Would be awesome and very useful if someone could add the categories & tags templates on the Craft demo site github.com/pixelandtonic/ontherocks ;)
Answers.UserDisplayName: lucassoares
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-27T01:13:49.063Z
Answers.Text: @lucassoares Sounds like somebody's got a great idea for a pull request! And by somebody, I mean you. :)
Answers.UserDisplayName: Matt Stein
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T20:33:45.517Z
Answers.LastActivityDate: 2014-06-27T16:25:56.220Z
Answers.LastEditDate: 2014-06-27T16:25:56.220Z
Answers.UserDisplayName: Ben Croker
Answers.Body: <pre><code>{% set category = craft.categories.group('{{ entry.topic }}').first() %}`enter code here`
  </code></pre>
  
  <p>For anyone else who stumbles on this post, I wasn't able to get the code working until I changed a few things.</p>
  
  <p>Instead of categories.<em>slug</em>, I used category.<em>group</em> and made 'your category-slug' {{ entry.topic }}, topic being how I assign my <em>single</em> category to entries.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-10T18:20:09.750Z
Answers.Text: Passing a string `'{{ entry.topic }}'` to the param works for you? Doesn't sound right...
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-11T22:20:07.007Z
Answers.Text: topic is how I call the single category name that I've assigned to my entries.
Answers.UserDisplayName: Aaron Ransom
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-10T14:35:28.917Z
Answers.LastActivityDate: 2016-04-10T14:35:28.917Z
Answers.UserDisplayName: Aaron Ransom
Body: <p>I'm converting a WordPress blog to Craft - first time playing with categories in Craft, so how can I display the related posts (by category) at the bottom of each post? </p>
  
Tags: <entries><categories><relations>
Title: How can I display the related posts (by category) at the bottom of each post?
ThreadText: # How can I display the related posts (by category) at the bottom of each post?
  
  (Asked by: username_0 on 2014-06-26)
  
  I'm converting a WordPress blog to Craft - first time playing with categories in Craft, so how can I display the related posts (by category) at the bottom of each post?
  
  **Tags:** entries, categories, relations
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2014-06-26. Score: 4
  
  This can be accomplished using Craft's [Relations](http://buildwithcraft.com/docs/relations).
  
  *My example code assumes you know the blog categories slug, and that you are pulling posts from a single category.*
  
  First, you'll have to get a reference to the [category ElementCriteriaModel](http://buildwithcraft.com/docs/templating/craft.categories) object pointing to the category of the blog post.
  
  ```
  {% set category = craft.categories.slug('your-category-slug').first() %}
  
  ```
  
  With a reference to the category model, you'll be able to find related entries.
  
  ```
  {% for post in craft.entries.section('blog').relatedTo({targetElement: category}) %}
      {% if post.id != entry.id %}
          <div class="related-entry">
              <h2>{{ post.title }}</h2>
              {{ post.body }}
          </div>
      {% endif %}
  {% endfor %}
  
  ```
  
  The if statement makes sure you aren't including the current post with the related posts.
  
  > **Comments:**
  > **username_2**: It is also probably worth throwing an if statement in the loop so you don't display the original entry as a related entry.  
  > **username_1**: Yeah, great call. I included that in the answer.  
  
  ---
  
  ### Answer by username_3 on 2014-06-26. Score: 4
  
  This can be done quite easily as follows, assuming that you are on an entry page so `entry` is a variable in your template and your category field is called `categories`.
  
  ```twig
  {% for relatedEntry in craft.entries({
      section: 'blog',
      relatedTo: entry.categories,
      id: 'not ' ~ entry.id
  }) %}
      <a href="{{ relatedEntry.url }}">{{ relatedEntry.title }}</a>
  {% endfor %}
  
  ```
  
  I am passing an object into the ElementCriteriaModel for clarity above but you could just as easily do it by chaining parameters onto the ElementCriteriaModel as follows, it's just a matter of preference.
  
  ```twig
  {% for relatedEntry in craft.entries.section('blog').relatedTo(entry.categories).id('not ' ~ entry.id) %}
      <a href="{{ relatedEntry.url }}">{{ relatedEntry.title }}</a>
  {% endfor %}
  
  ```
  
  See [the relatedTo param](http://buildwithcraft.com/docs/relations#the-relatedTo-param) in the docs to understand the magic.
  
  > **Comments:**
  > **username_0**: Thanks guys! :) Would be awesome and very useful if someone could add the categories & tags templates on the Craft demo site github.com/pixelandtonic/ontherocks ;)  
  > **username_4**: @username_0 Sounds like somebody's got a great idea for a pull request! And by somebody, I mean you. :)  
  
  ---
  
  ### Answer by username_5 on 2016-04-10. Score: 1
  
  ```
  {% set category = craft.categories.group('{{ entry.topic }}').first() %}`enter code here`
  
  ```
  
  For anyone else who stumbles on this post, I wasn't able to get the code working until I changed a few things.
  
  Instead of categories.*slug*, I used category.*group* and made 'your category-slug' {{ entry.topic }}, topic being how I assign my *single* category to entries.
  
  > **Comments:**
  > **username_6**: Passing a string `'{{ entry.topic }}'` to the param works for you? Doesn't sound right...  
  > **username_5**: topic is how I call the single category name that I've assigned to my entries.  
  
  ---
  
  