Closed reekes closed 4 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.
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' );
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.
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!
@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.
@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.
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.
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?
Technical info
Used versions
SEO settings