Is there any way to set entries of an certain entry type to auto-expire after a certain number of days from the original post date?

2 Answers 2


There's no build in functionality for this, but you could make a custom plugin that automatically sets the expiration date expiryDate when you first save an entry with a specific entry type.

Another option would be to simply filter your entries from your template:

{% set entries = craft.entries.type('myEntryType').postDate('>= ' ~ now|date_modify('-10 days')) %}



Here's a description for the expression used as the value for the date_modify parameter.

Have a look at the syntax for parameter values in the Craft docs. And also how the date_modify filter works. now|date_modify('-10 days') returns a string which is then concatenated with the string '>= ' and then passed as a value to the postDate() parameter.

  • hi @carlcs. can you please give me more details on .postDate('>= ' ~ now|date_modify('-10 days'))? Commented Aug 19, 2014 at 13:40
  • @lucassoares - carlcs postDate parameter is saying, make sure that he post date is greater than or equal to the timestamp of 10 days ago. It will guarantee that the entries returned are newer than 10 days old.
    – Wes Rice
    Commented Aug 19, 2014 at 16:00
  • @Wes This is a nice description on what happens if you apply the parameter on a ElementCriteriaModel. I altered my answer to make it easier to understand the syntax used.
    – carlcs
    Commented Aug 19, 2014 at 16:24
  • @WesRice that would make entries to become expired after 10 days from current date or it would just have their date modified to 10 days earlier from current date? Commented Aug 19, 2014 at 16:57
  • @lucassoares both wrong. As I tried to explain in the answer, the only way to automatically set the expiration date is with a plugin. And the code example doesn't modify your entry in the DB. It is used in your template as a filter on an ElementCriteriaModel. If you use it like so, only entries newer then 10 days from the current moment 'now' are returned. Compare it to the parameter section() where only entries from select sections are returned!
    – carlcs
    Commented Aug 19, 2014 at 17:02

You could use my Auto Expire plugin for this. Just add a new expiration rule with the expiration date set to:

{ postDate|date_modify('+14 days 5am')|date('c') }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.