Yoast / wordpress-seo

Yoast SEO for WordPress
https://yoast.com/wordpress/plugins/seo/
Other
1.77k stars 891 forks source link

author name field is invalid #13315

Closed reekes closed 4 years ago

reekes commented 5 years ago

Please give us a description of what happened.

I have two custom post types used for technical articles. When I include them to use the Article schema type (wpseo_schema_article_post_types), the author name fails.

Using the Google Schema Checker, the Author's Name field is reported as "A value for the name field is required."

Checking the page source, I see "author":{"@id":"https://MY-SITE-DOMAIN/#/schema/person/11c8081e306d704cd7ae40aa2607ca0a"} and nothing more. Looks like all of the author data is missing.

My blog pages are working but not custom posts.

Please describe what you expected to happen and why.

Author schema must be correctly and completely provided.

How can we reproduce this behavior?

  1. create a custom post type (make it just like a blog post, not much more to it)
  2. create content and set the author in the custom post
  3. add the custom post type using the wpseo_schema_article_post_types filter

Technical info

Used versions

SEO settings

Djennez commented 5 years ago

Hi @reekes and thank you for your report.

Just checked this internally and the author schema should indeed get provided when converting a posttype to article that way. I've labelled this as a bug.

In the meantime you might want to add the author name manually with the wpseo_schema_article filter.

reekes commented 5 years ago

Here's my code based on the docs, but it's not working. The problem seems to be the author data structure is incomplete (e.g. 'name' is missing).

// temporary workaround to a bug in Yoast function change_schema_author( $data ) { $data['name'] = 'My Name'; return $data; } add_filter( 'wpseo_schema_author', 'change_schema_author' );

Djennez commented 5 years ago

You'd need to hook into wpseo_schema_article, rather than wpseo_schema_author, as name is part of article. This is how I got mine to work:

add_filter( 'wpseo_schema_article', 'example_change_article_authorname' );

function example_change_article_authorname( $data ) {
    $data['author']['name'] = 'MYNAME';
    return $data;
}

Please note that this will change the name of ALL articles on your site. So from the normal posts as well. If your name is the same everywhere that would be fine, but if it's different in certain cases you will have to program logic to check for the right articles to change the name of.

jreynolds13 commented 5 years ago

I'm seeing this issue as well after updating from 11.1, but for all posts on the site rather than just custom post type posts. The author's name IS showing up under ["Person"]. I noticed in the release notes for 11.3 a note saying "Removes redundant name attribute from author in Article schema markup piece", so it would seem this is intentional... is there a reason for removing the name attribute from author and putting it in person? Thanks!

Djennez commented 4 years ago

@reekes I was wondering if this is still relevant on the latest version, seeing as we've changed quite a lot in regards to building this schema and the indexables.

cyphereye-devops commented 4 years ago

@Djennez adding the author is always relevant, as it's part of the required fields in an article schema. That said, testing it just now it looks like this bug was fixed.

Djennez commented 4 years ago

Thank you @cyphereye-devops , seeing if this issue was still around was the intent of my asking if this was still relevant :) If it's fixed, I'm going to go ahead and close this thread. Feel free to provide more info if it turns out to not be fixed.