I have a channel where I need each entry's Title include a sequential number, like this: 10003 - Entry Title

Is there a way to prepend a sequential number to the entry title?


I think you'll need to implement this with the Elements::EVENT_AFTER_SAVE_ELEMENT event and keep a record of the number.

If it doesn't need to be sequential 1,2,3 you could use a dynamic title and use {{object.sourceId}} which would be the entry id which will always increment

  • Yeah, this. I wondered about using something like {craft.entries.section('pages')|length} in the Title Format field, but that would update the number to the total length every time you updated the entry. You may still run into problems with the user being able to change the number when they edit the page. Jun 22 '20 at 11:14

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.