4

How can I add a counter or something similar to my entries, so that I could loop through the most read articles?

nicael
  • 2,382
  • 7
  • 27
  • 48
Wobee
  • 328
  • 2
  • 9

2 Answers2

3

Updated: There is an Entry Count plugin that is designed to do exactly this, written by Ben Croker. Thanks Ben!

Douglas McDonald
  • 13,457
  • 24
  • 57
1

The Entry Count plugin will do this for you (previously the Counter plugin).

You can loop through the most read articles as follows:

{% set countedEntries = craft.entryCount.entries %}

{% for entry in countedEntries %}
    {% set count = craft.entryCount.count(entry.id) %}
    {{ entry.title }} ({{ count }} views)
{% endfor %}
Ben Croker
  • 7,341
  • 26
  • 55