fix: output the article:published_time meta tag on pages#23441
Open
TowyTowy wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
article:modified_timeand thedatePublishedschema property, but notarticle:published_time. In the issue, Yoast confirmed the intended behaviour: "On post and page post types, we should output both of these tags. On other post types, we should not output either."Indexable_Post_Type_Presentation::generate_open_graph_article_published_time()gated the tag to thepostobject sub type only, so pages fell through to thewpseo_opengraph_show_publish_datefilter (defaultfalse) and returned an empty value.posttype", which appears to describe the current (buggy) behaviour rather than the intent confirmed in The conditional tag article:published_time outputs for posts but not for pages #21433. If the specification is leading instead, feel free to close this PR in favour of a documentation update and to close The conditional tag article:published_time outputs for posts but not for pages #21433 accordingly.composer test, green) in a PHP 7.4 container. I could not runcomposer test-wp-env(Docker-in-Docker constraints in my environment); no WP integration tests cover this generator, so reviewers may want to do a quick manual front-end check using the test instructions below.Summary
This PR can be summarized in the following changelog entry:
article:published_timemeta tag was not output on pages.Relevant technical choices:
pagesub type was added to the existing guard; custom post types keep thewpseo_opengraph_show_publish_datefilter opt-in, and thearticle:modified_timebehaviour is untouched.wpseo_opengraph_show_publish_datefilter is no longer applied for pages. The filter could previously only opt pages in (defaultfalseshort-circuits to an empty value), so no opt-out behaviour is lost.book) so the filter behaviour keeps its coverage.Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
<meta property="article:published_time" content="..." />tag is present in the Yoast SEO output.article:modified_timeis also present.article:published_timeis still output there, as before.article:published_time, unless thewpseo_opengraph_show_publish_datefilter returnstruefor it.Relevant test scenarios
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 can test this PR by following these steps:
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
Other environments
[shopify-seo], added test instructions for Shopify and attached theShopifylabel to this PR.[yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached theGoogle Docs Add-onlabel to this PR.Documentation
(The OpenGraph functional specification on developer.yoast.com will need a small follow-up edit — "Only populated on the
posttype" becomes "thepostandpagetypes" — which I cannot make from this repository; flagged in Context.)Quality assurance
grunt build:imagesand committed the results, if my PR introduces or edits images or SVGs.Innovation
Fixes #21433