Skip to content

fix: output the article:published_time meta tag on pages#23441

Open
TowyTowy wants to merge 1 commit into
Yoast:trunkfrom
TowyTowy:fix/21433-article-published-time-pages
Open

fix: output the article:published_time meta tag on pages#23441
TowyTowy wants to merge 1 commit into
Yoast:trunkfrom
TowyTowy:fix/21433-article-published-time-pages

Conversation

@TowyTowy

Copy link
Copy Markdown

Context

Summary

This PR can be summarized in the following changelog entry:

  • Fixes a bug where the article:published_time meta tag was not output on pages.

Relevant technical choices:

  • Only the page sub type was added to the existing guard; custom post types keep the wpseo_opengraph_show_publish_date filter opt-in, and the article:modified_time behaviour is untouched.
  • Because pages now always output the tag, the wpseo_opengraph_show_publish_date filter is no longer applied for pages. The filter could previously only opt pages in (default false short-circuits to an empty value), so no opt-out behaviour is lost.
  • The unit test for pages now expects the published time to be returned, and the filter tests were moved to a custom post type (book) so the filter behaviour keeps its coverage.
  • Disclosure: this patch was written with the assistance of an AI coding agent (Claude, by Anthropic), operated and reviewed by the PR author. Regarding the licensing note in the contribution guidelines: the change is a one-line logic tweak plus test updates modelled on the pre-existing test file — no external code was copied.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Create and publish a new page.
  • View the page on the front end and inspect the page source.
  • Verify a <meta property="article:published_time" content="..." /> tag is present in the Yoast SEO output.
  • Edit the page, save it, revisit the front end and verify article:modified_time is also present.
  • Create and publish a post and verify article:published_time is still output there, as before.
  • Register a custom post type, publish an item and verify it still outputs no article:published_time, unless the wpseo_opengraph_show_publish_date filter returns true for it.

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Pages are the changed surface; posts and custom post types should be regression-checked as described in the steps above. Note that a static front page is a page, so it will now also output article:published_time.

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • Front-end Open Graph output for pages (including static front pages).

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.
  • This PR also affects Yoast SEO for Google Docs. I have added a changelog entry starting with [yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached the Google Docs Add-on label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

(The OpenGraph functional specification on developer.yoast.com will need a small follow-up edit — "Only populated on the post type" becomes "the post and page types" — which I cannot make from this repository; flagged in Context.)

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.
  • I have run grunt build:images and committed the results, if my PR introduces or edits images or SVGs.

Innovation

  • No innovation project is applicable for this PR.

Fixes #21433

The article:published_time Open Graph meta tag was only generated for
the post object sub type, while pages already output the matching
article:modified_time tag and the datePublished schema property.

Yoast confirmed in Yoast#21433 that both tags should be output on posts and
pages, so the page sub type is now allowed as well. Custom post types
keep the existing wpseo_opengraph_show_publish_date filter opt-in.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The conditional tag article:published_time outputs for posts but not for pages

2 participants