Skip to content

Fix author meta tag suppressed for CPTs with author support#23409

Open
thisismyurl wants to merge 1 commit into
Yoast:trunkfrom
thisismyurl:fix/23193-cpt-author-meta-tag
Open

Fix author meta tag suppressed for CPTs with author support#23409
thisismyurl wants to merge 1 commit into
Yoast:trunkfrom
thisismyurl:fix/23193-cpt-author-meta-tag

Conversation

@thisismyurl

Copy link
Copy Markdown

Description

Custom post types configured with 'author' in their supports array do not output the author meta tag, even when using the wpseo_meta_author filter — the filter is never reached for any object_sub_type that isn't the literal string 'post'.

Root cause: Meta_Author_Presenter::get() contains a guard that compares object_sub_type against the hardcoded string 'post' and bails out before the wpseo_meta_author filter can fire for any other post type.

Before:

if ( $this->presentation->model->object_sub_type !== 'post' ) {
    return '';
}

Fix: Replace the hardcoded equality check with post_type_supports():

if ( ! \post_type_supports( $this->presentation->model->object_sub_type, 'author' ) ) {
    return '';
}

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

  1. Register a CPT with 'supports' => [ 'title', 'editor', 'author' ]
  2. Create a post of that type and view it on the frontend
  3. Check page source — <meta name="author" content="..." /> should appear
  4. Optionally add a wpseo_meta_author filter — confirm it fires and the return value is used

Changelog label

Could a maintainer please apply changelog: bugfix? As an external contributor I'm unable to add labels, and I understand pr-validation.yml requires one before merge.

Credits

props @thisismyurl (full disclosure: AI helped me identify the issue and verify my work)

Closes #23193

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>
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.

[Bug]: CPT not outputting author meta tag

2 participants