Sort by highest voted
You can sort your results to display the highest voted elements first!
Create an Element Query (opens new window) just as you normally would, then pass the Element Query into the sort
method.
{% set hotels = craft.entries.section('hotels') %}
{% do craft.upvote.sort(hotels) %}
If you want to sort by a specific key, simply add it as the second parameter...
{% do craft.upvote.sort(hotels, 'comfortable') %}
Votes can be assigned to any valid element type, whether it's native or 3rd party.
Must be an Element Query
Don't apply the .all()
method until after you have sorted the Element Query.