fix(post-date): preserve classic theme markup and fix archive titles#4602
fix(post-date): preserve classic theme markup and fix archive titles#4602rbcorrales merged 3 commits intotrunkfrom
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adjusts the Post Date feature integration to better match the classic Newspack theme’s historical markup while preventing relative-date formatting from leaking into archive titles.
Changes:
- Switch classic-theme updated-date injection to the new
newspack_theme_posted_onhook and adjust classic updated-date HTML output to match legacy markup. - Prevent
get_the_date“time ago” conversion from applying outside the loop (fixes archive title regressions). - Update the relative-time JS to also target
time.updated[datetime]and remove the plugin’s classic updated-date inline CSS.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
includes/class-post-date.php |
Renames the classic-theme hook, updates classic updated-date markup, removes inline CSS, and adds an in_the_loop() guard in get_the_date filtering. |
src/other-scripts/relative-time/index.js |
Expands the selector to include time.updated[datetime] so classic updated dates get tooltips/updates. |
tests/unit-tests/class-post-date-test.php |
Updates the get_the_date filter test to simulate being “in the loop”. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
laurelfulford
left a comment
There was a problem hiding this comment.
I haven't had a chance to give this one a full review yet (sorry!), but it looks like the hidden 'updated' dates might be missing -- this is something that some publishers are using CSS to show to "roll their own" show updated date option.
When I edit a post, I get:
... compared to the same post in the Content Loop block -- the markup does differ, but the bit that's missing from the single post is the second, hidden <time> tag.
That second <time> should start showing up as soon as the post it edited.
It's a weird edge case for folks using this, but it'd be nice to preserve it!
|
@laurelfulford good catch! I missed that on the previous theme PR. The hidden
|
laurelfulford
left a comment
There was a problem hiding this comment.
Thanks @rbcorrales!
The markup looks good! One remaining issue: the updated CSS now hides the updated date when you want to show it 😅
This was previously shown in the theme by adding a CSS class on the body, and using it to style the date as visible:
// Add a class if updated date should display
if ( newspack_should_display_updated_date() ) {
$classes[] = 'show-updated';
}
.show-updated .entry-header .updated:not(.published) {
display: inline-block;
}
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@laurelfulford thank you for spotting this. Fixed in b998513 and 4d0975f (theme). The tricky part was avoiding a duplicate The fix adds a filter ( Tested:
|
laurelfulford
left a comment
There was a problem hiding this comment.
Thanks @rbcorrales! This looks good to me - I also tested with a snippet of CSS used by a publisher to manipulate how the dates look, still works as expected with this change! 🎉
|
Hey @rbcorrales, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |
# [6.37.0-alpha.1](v6.36.1...v6.37.0-alpha.1) (2026-04-02) ### Bug Fixes * **card-settings-group:** change default actionType from chevron to none ([#4610](#4610)) ([00505ed](00505ed)) * **post-date:** preserve classic theme markup and fix archive titles ([#4602](#4602)) ([c5fb825](c5fb825)) * remove removal of block visibility ([#4595](#4595)) ([9396379](9396379)) ### Features * **access-control:** filter available lists by content restrictions ([#4589](#4589)) ([959127f](959127f)), closes [#4581](#4581) [#4583](#4583) [#4590](#4590) * **access-control:** premium newsletters UI ([#4577](#4577)) ([6f8c891](6f8c891)), closes [#4581](#4581) [#4583](#4583) [#4590](#4590) * **author-profile-social:** add support for colors, block spacing, brand style ([#4509](#4509)) ([21cf4c9](21cf4c9)) * campaigns wizard light UI refresh ([#4588](#4588)) ([6078c4b](6078c4b)) * **color-picker:** simplify component to use basecontrol ([#4581](#4581)) ([ff677ea](ff677ea)) * **components:** add CardFeature component ([#4583](#4583)) ([5aabb18](5aabb18)) * **content-gate:** institution management ui ([#4582](#4582)) ([ae88750](ae88750)) * **content-gate:** institutional access redirect and loading UX ([#4593](#4593)) ([548d236](548d236)) * **content-gate:** institutions ([#4574](#4574)) ([49b0c05](49b0c05)) * **content-gate:** personalized institutional access verification page ([#4596](#4596)) ([0eed591](0eed591)) * **image-upload:** simplify component to use basecontrol; remove info prop ([#4580](#4580)) ([d51eb54](d51eb54)) * **integrations:** add ActionScheduler group handling ([#4559](#4559)) ([411732a](411732a)) * **integrations:** promoted fields for content gate and campaign segmentation ([#4601](#4601)) ([f943df2](f943df2)) * **newspack-ui:** add stack layout and color utility classes ([#4600](#4600)) ([1934067](1934067)) * **post-date:** centralize date features from theme into plugin ([#4579](#4579)) ([19f15eb](19f15eb)) * **sync:** prevent stale data on retry, improve logging and error handling ([#4562](#4562)) ([5467f34](5467f34)) * **tags:** add private tags feature ([#4507](#4507)) ([06d7711](06d7711)) * **yoast:** add primary category utility and settings toggle ([#4563](#4563)) ([4b396c3](4b396c3))
|
🎉 This PR is included in version 6.37.0-alpha.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |

All Submissions:
Changes proposed in this Pull Request:
Follow-up to #4579. Addresses review feedback from @laurelfulford about preserving the classic theme's HTML markup for the updated date, and fixes the archive title regression.
newspack_theme_after_posted_ontonewspack_theme_posted_on(now fires insidenewspack_posted_on()in the theme)<span class="updated-label">+<time class="updated">) matching the old theme markup exactly.updated-date(theme provides.updated-labelstyling)in_the_loop()guard tofilter_get_the_dateto prevent archive titles showing relative dates (e.g. "Daily Archives: 2 days ago")time.updated[datetime]to the relative-time JS selector so the updated date gets a hover tooltip on classic themesRequires companion theme PR: Automattic/newspack-theme#2658. Must ship together.
Closes NPPD-1278.
How to test the changes in this Pull Request:
.posted-onspan:<time class="entry-date published">+<span class="updated-label">Updated </span>+<time class="updated">.data-newspack-modifiedandwp-block-post-date__modified-date.Other information: