Answers.Body: <p>You can use the <a href="https://plugins.craftcms.com/similar" rel="nofollow noreferrer">Similar plugin</a> for this. I don't know that you can do it natively otherwise.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-01T08:01:09.793Z
Answers.Text: Thanks Jeremy - I'll take a look
Answers.UserDisplayName: Clifford
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-29T03:28:54.380Z
Answers.LastActivityDate: 2019-10-29T03:28:54.380Z
Answers.UserDisplayName: Jeremy Gimbel
Body: <p>I'm creating a list of similar entries which displays entries that share the same categories as the current entry. My code looks like this:</p>
  
  <pre><code>{% set categories = craft.categories.relatedTo(entry) %}
  {% set entries = craft.entries.section('projects').relatedTo( categories ).id('not ' ~ entry.id) %}
  {% for project in entries %}                    
      &lt;a href="{{ project.url }}"&gt;{{ project.title }}&lt;/a&gt;&lt;br/&gt;
  {% endfor %}
  </code></pre>
  
  <p>Many of my entries have multiple categories. Is it possible to order the list so that entries with the most categories in common with the current entry are at the top? And if not, is there another solution that would do this?</p>
  
Tags: <craft3><categories>
Title: Order related entries by number of categories they have in common with current entry
ThreadText: # Order related entries by number of categories they have in common with current entry
  
  (Asked by: username_0 on 2019-10-20)
  
  I'm creating a list of similar entries which displays entries that share the same categories as the current entry. My code looks like this:
  
  ```
  {% set categories = craft.categories.relatedTo(entry) %}
  {% set entries = craft.entries.section('projects').relatedTo( categories ).id('not ' ~ entry.id) %}
  {% for project in entries %}                    
      <a href="{{ project.url }}">{{ project.title }}</a><br/>
  {% endfor %}
  
  ```
  
  Many of my entries have multiple categories. Is it possible to order the list so that entries with the most categories in common with the current entry are at the top? And if not, is there another solution that would do this?
  
  **Tags:** craft3, categories
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-10-29. Score: 0 | Accepted answer
  
  You can use the [Similar plugin](https://plugins.craftcms.com/similar) for this. I don't know that you can do it natively otherwise.
  
  > **Comments:**
  > **username_0**: Thanks username_1 - I'll take a look  
  
  ---
  
  