Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post Date block doesn't show the modified date for newly published posts #57915

Open
bugnumber9 opened this issue Jan 17, 2024 · 10 comments
Open
Labels
[Block] Post Date Affects the Post Date Block [Type] Bug An existing feature does not function as intended

Comments

@bugnumber9
Copy link

Description

When a new post is published and hasn't been modified after publishing, the Post Date block doesn't show the modified date.

I confirmed that get_the_modified_date function works as expected in a non-FSE theme (Hello theme) by altering the code in single.php as shown here:
hello
The output is expected:
frontend2

However, when I change a single post template in site editor (standard 2024 theme) as shown here:
site-editor
The modified date on the frontend is empty:
frontend

Step-by-step reproduction instructions

Shown above.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@bugnumber9 bugnumber9 added the [Type] Bug An existing feature does not function as intended label Jan 17, 2024
@benniledl
Copy link
Contributor

I see, that this was the most recent change in the post date block and was intentional: #46839

@benniledl
Copy link
Contributor

@bugnumber9 I recommend using
get_the_modified_date() ? get_the_modified_date() : get_the_date();
This returns the modified date and if that is empty it returns the normal date

@bugnumber9
Copy link
Author

Well, this is a bit weird.
Let's say, I want to show the "last updated" not "created" date in the postmeta section (using FSE) - it won't show for posts that weren't modified after publishing.
I was able to create a workaround using Block Logic and a custom PHP function, but it's surely not ideal.

@benniledl
Copy link
Contributor

@bugnumber9 you don't need an extra function you can just do
echo 'Modified: ' . get_the_modified_date() ? get_the_modified_date() : get_the_date();

@bugnumber9
Copy link
Author

bugnumber9 commented Jan 17, 2024

@bugnumber9 you don't need an extra function you can just do echo 'Modified: ' . get_the_modified_date() ? get_the_modified_date() : get_the_date();

I'm using FSE theme and I use Post Date block in postmeta template.

Besides that, both get_the_date and get_the_modified_date functions always return dates, so in PHP I can just do echo 'Modified: ' . get_the_modified_date(); and it'll always work.

It's the Post Date block behavior that I find weird in this case because I can't reliably use <!-- wp:post-date {"displayType":"modified"} /--> where I need to.

@carolinan
Copy link
Contributor

We need to think about how can we satisfy both these requests without making the block options too complex.

@bugnumber9
Copy link
Author

@carolinan IMO the block should behave just like get_the_date and get_the_modified_date functions.
In other words, <!-- wp:post-date {"displayType":"modified"} /--> should always return the date.
If I make a decision to use two date blocks to display published and modified dates - I realize they may be the same in some cases. So this now falls into the block display logic realm.

Besides that, the current behavior will still display two identical dates if the post was edited, say, several minutes after publishing which kinda defeats the purpose of #46839
While there's no native block display logic functionality in Gutenberg, 3rs party solutions exist and this is where the show/hide logic should reside.

@carolinan
Copy link
Contributor

And that is your opinion, please respect that there are other users who have expressed different needs.

@bugnumber9
Copy link
Author

And that is your opinion, please respect that there are other users who have expressed different needs.

Yes, absolutely. It's just my opinion of course, and I was able to achieve the behavior I wanted using a 3rd party block display logic plugin to fall back to published date.
All I'm saying is that I find the current behavior somewhat weird (again, maybe it's just me) because it a) doesn't completely prevent showing 2 identical dates, and b) makes it impossible to use <!-- wp:post-date {"displayType":"modified"} /--> if I want to only show the modified date as it'll be empty in some cases.

That being said, the display logic of both published and modified dates is often a matter of personal preferences or project requirements.
E.g. one of the projects I've built required that modified date is only publicly displayed if the difference between published and modified dates is 4 weeks or more yet is always visible to the editorial team. This is easy to do in the non-FSE theme in several possible ways, but that would usually be either hard code or ACF-like approach.
I can't imagine a reasonably simple way to move the display logic to block controls and satisfy varying needs, thus mentioned that IMO this falls into block display logic realm rather than block behavior or controls.

Just my 2.5 cents :)

@carolinan
Copy link
Contributor

I personally don't find it strange that the modified date literally only shows if the post has been modified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Date Affects the Post Date Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants