Co-Authors-Plus icon indicating copy to clipboard operation
Co-Authors-Plus copied to clipboard

Integrate with Yoast's new Schema API

Open WPprodigy opened this issue 5 years ago • 11 comments

Info: https://yoast.com/yoast-seo-11-0/

Extending docs: https://developer.yoast.com/features/schema/api/#add-or-remove-graph-pieces

CAP should ensure it uses the co-author data and not the core WP author data.

WPprodigy avatar Oct 25 '19 11:10 WPprodigy

i've just encountered this problem. i started working around it, i'll post my hacks when i get something useful working.

things that (i noticed) work incorrectly on my site:

schema.org metadata in <head>

  • Articles "written by" guest authors have their author attribute set to the user who created the post instead. (check yours with google's tool)

  • guest author archive ProfilePages aren't linked to the correct Person

misc

  • titles of author archives for guest authors. right now Yoast tries to look up the user with the id of the guest-author post¹ and understandably get either null or garbage data. in some places, they seem to use the data of the actual user who created the guest-author e.g. the %%name%% snippet variable used for the page's title.

i'm afraid the fix will be pretty ugly and/or it will duplicate a bunch of Yoast's logic. they seem to assume the author is a user in multiple disconnected places :/


  1. ...because they use get_queried_object_id which returns the guest-author post, and they're expecting a user id

lubieowoce avatar Oct 26 '19 17:10 lubieowoce

Here's the integration code i hacked together:

https://gist.github.com/lubieowoce/46d917b10a85d4195185dff347db9206

i'm still improving it (and updating the gist as i go), but it fixes the problems i had. it's probably not very robust and makes some site-specific assumptions¹, so please read the code before using it – i did my best to document them (comments starting with NOTE: ...). any ideas for improving it are welcome!


  1. e.g. we only publish works submitted by external authors, so the user who created the post doesn't matter; the real author is added via guest-authors. none of the guest-authors are assigned to real users

lubieowoce avatar Oct 27 '19 15:10 lubieowoce

I think we're having the same issue.

Google Search Console has detected a covarage issue. Every Co-Author page have the meta tag robots set to noindex, follow instead of index, follow. (This is set by Yoast)
After investigating I found out that the schema and the og:url have some wrong data as well (also set by Yoast).

And now here I am...

@lubieowoce do you have your fix still in production? Where did you add the fix?

mekanics avatar Aug 27 '20 12:08 mekanics

@mekanics my fix required some modifications after updating to Yoast 14 bc they changed a whole bunch of stuff, but yeah, it's still running :) i'll post the new version here soon.

Where did you add the fix?

the code just does a bunch of add_action/add_filter, so you can add it wherever, even copypaste it into your functions.php or put it in a file and include it

PS. does your site have a user for each guest_author? mine doesn't, and I wrote the fix with that in mind, so it could require some tweaking

lubieowoce avatar Aug 30 '20 12:08 lubieowoce

@lubieowoce thank you very much! So I guess, we will have to try your solution as soon has we find time.

does your site have a user for each guest_author?

No, they don't have one either – lucky us 😉

mekanics avatar Sep 16 '20 09:09 mekanics

Looks like Yoast is adding a filter for modifying the schema author data in v16.3, which should make this change much simpler. This feature marches closer to completion!

claudiulodro avatar Apr 30 '21 19:04 claudiulodro

Any update on this one?

anteksiler avatar Jun 21 '21 15:06 anteksiler

@anteksiler Feel free to open a PR!

rebeccahum avatar Jun 22 '21 17:06 rebeccahum

Hello everyone, I've got some news:

Recently Yoast added an integration with CoAuthors Plus in its core:

https://github.com/Yoast/wordpress-seo/pull/18161

From what I could see, it now supports multiple authors for a post, but it does not support guest authors yet.

I've started working on this and the help from everyone here with testing, validating and (even better) some code would be awesome. Once we have this ready we can open a PR to the official Yoast repository:

https://github.com/leogermani/wordpress-seo/pull/1

I'm new to both CoAuthors Plus and Yoast, so getting an eye from some of you who know this issue in more depth would be great.

cc @lubieowoce

leogermani avatar Oct 05 '22 18:10 leogermani

I think I've managed to address all the issues we found. There's a PR to the Yoast repo now:

https://github.com/Yoast/wordpress-seo/pull/19076

leogermani avatar Oct 19 '22 17:10 leogermani

Hello,

Following the comments here and in https://github.com/Yoast/wordpress-seo/pull/19076 and https://github.com/Automattic/Co-Authors-Plus/pull/877 but noticing that neither the Person or ProfilePage schema is appearing on single Guest Author pages when testing. In the Yoast settings I have the Guest Authors post type Schema set to Profile.

bjorn2404 avatar Apr 27 '24 00:04 bjorn2404