Fix author meta tag suppressed for CPTs with author support#23409
Open
thisismyurl wants to merge 1 commit into
Open
Fix author meta tag suppressed for CPTs with author support#23409thisismyurl wants to merge 1 commit into
thisismyurl wants to merge 1 commit into
Conversation
The guard in Meta_Author_Presenter::get() compared object_sub_type against the literal string 'post', which silently blocked the author meta tag and the wpseo_meta_author filter for every custom post type, even those that explicitly declare author support. Replace the hardcoded equality check with post_type_supports() so the tag is emitted for any post type that supports the 'author' feature — including built-in types and CPTs registered with that support — while remaining suppressed for types that do not. Fixes Yoast#23193 Co-Authored-By: Claude Sonnet 4.6 <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.
Description
Custom post types configured with
'author'in theirsupportsarray do not output the author meta tag, even when using thewpseo_meta_authorfilter — the filter is never reached for anyobject_sub_typethat isn't the literal string'post'.Root cause:
Meta_Author_Presenter::get()contains a guard that comparesobject_sub_typeagainst the hardcoded string'post'and bails out before thewpseo_meta_authorfilter can fire for any other post type.Before:
Fix: Replace the hardcoded equality check with
post_type_supports():The tag is now emitted for any post type that declares
'author'support — including built-in types that already had it and CPTs registered with that support. Types without the feature continue to receive no tag.How to test
'supports' => [ 'title', 'editor', 'author' ]<meta name="author" content="..." />should appearwpseo_meta_authorfilter — confirm it fires and the return value is usedChangelog label
Could a maintainer please apply
changelog: bugfix? As an external contributor I'm unable to add labels, and I understandpr-validation.ymlrequires one before merge.Credits
props @thisismyurl (full disclosure: AI helped me identify the issue and verify my work)
Closes #23193