Make WordPress Core

Opened 4 months ago

Closed 4 months ago

Last modified 4 months ago

#60266 closed defect (bug) (worksforme)

get_the_modified_date function doesn't return the date for newly published posts

Reported by: bugnumber9's profile bugnumber9 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)

#1 follow-up: @benniledl
4 months ago

  • Resolution set to worksforme
  • Status changed from new to closed

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?

#2 in reply to: ↑ 1 @bugnumber9
4 months 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 @benniledl
4 months 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

#4 @swissspidy
4 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.