0

We are using getVersionsByEntryId in our XML sitemap to return the number of times an entry has been saved, then comparing that with todays date and the date the entry was created to determine the changefreq over that time:

{% set revisions = craft.app.entryRevisions.getVersionsByEntryId(element.id)|default(1)|length %}

Looking at the docs however, this is now deprecated:

DEPRECATED

Deprecated in 3.2. Use an entry query instead.

I can't seem to find anything in the docs for an entry query? Could someone point me in the right direction?

  • 1
    I think this is what you need - docs.craftcms.com/v3/dev/element-queries/… – Oli Oct 24 '19 at 13:07
  • 1
    Cheers Oli, that's exactly what I needed: {% set revisions = craft.entries.revisionOf(element.id).all|default(1) %}. Please post that as an answer and I'll accept :-) – Jamie Wade Oct 24 '19 at 14:32
2

You can use the revisionOf parameter (docs).

{% set revisions = craft.entries.revisionOf(element.id).all|default(1) %}
  • 1
    Thanks again Oli! – Jamie Wade Oct 25 '19 at 12:59

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.