0

we are using multi-site setup to run 2 websites in different languages. We share articles between both sites and display some of them on the home page as "recent articles". Since the translation of every article take some time, the article is not enabled on both websites at the same date/time.

Shouldn't the post date be different for every website? Is there a way to display recent articles by the post date for the specific website?

Thanks

1 Answer 1

1

Shouldn't the post date be different for every website?

The post date isn't translatable, so it's always the same in all sites an entry is propagated to. Changing the post date in one entry will change it for all sites. That's by design, though you can always create a discussion on GitHub if you don't agree with this design.

However, you're not forced to utilize the post date in your frontend. In this case it's only relevant internally, to sort entries by the time they were created (though the post date can still be changed manually).

Is there a way to display recent articles by the post date for the specific website?

If you need a publication date for entries that is different between the two sites, I would just use a custom field. For example, create a date field publication_date and set it to Translate for each site. Set the field to required so every entry has a publication date. Then you can sort by that field in your templates:

{% set recentArticles = craft.entries()
    .section('articles')
    .orderBy('publication_date DESC')
    .limit(5)
    .all()
%}

You could even use a hook on Entry::EVENT_BEFORE_SAVE to set the publication date to the current date and time when a new article entry is created.

1
  • 1
    I definitely think that the post date should be translatable. Thank you Moritz. Commented Sep 27, 2023 at 12:34

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.