#60266 closed defect (bug) (worksforme)
get_the_modified_date function doesn't return the date for newly published posts
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Date/Time | Keywords: | |
| Focuses: | Cc: |
Description
When a new post is published, both post_date and post_modified columns contain equal values (which makes total sense).
However, when I use get_the_modified_date function - it doesn't return anything if a post hasn't been modified after publishing. This doesn't make sense to me since the value is there in the database.
So when I want to show something like "last updated" in the postmeta section - I first have to check if get_the_modified_date returns anything and fall back to get_the_date if it doesn't.
This seems weird, why wouldn't it return the value from the database?
Change History (4)
#2
in reply to:
↑ 1
@
2 years ago
Replying to benniledl:
Hey!
Please double check if you are experiencing the same behavior on a clean WordPress installation. I tried it with 6.4.2 and it works as you described. It returns the value from the database even tho creation and modification date are the same.
Maybe a plugin is altering the behavior or do you have a different WordPress version installed?
Thanks for pointing me in the right direction.
The issue is with Post Date block in block editor. I just confirmed that the function works as expected in non-FSE themes.
False alarm, sorry. I'm going to open an issue in Gutenberg repo.
#3
@
2 years ago
I see that this was the latest change in the post date block, to only show the date when the post was modified: https://github.com/WordPress/gutenberg/commit/faa4899055e3d4a0ca6b551497aa6348c65db645
Hey!
Please double check if you are experiencing the same behavior on a clean WordPress installation. I tried it with 6.4.2 and it works as you described. It returns the value from the database even tho creation and modification date are the same.
Maybe a plugin is altering the behavior or do you have a different WordPress version installed?