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?


You can use the Similar plugin for this. I don't know that you can do it natively otherwise.

  • Thanks Jeremy - I'll take a look
    – Clifford
    Nov 1 '19 at 8:01

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.