Automattic / Co-Authors-Plus

Multiple bylines and Guest Authors for WordPress
https://wordpress.org/plugins/co-authors-plus/
GNU General Public License v2.0
292 stars 205 forks source link

Integrate with Yoast's new Schema API #710

Open WPprodigy opened 4 years ago

WPprodigy commented 4 years ago

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.

lubieowoce commented 4 years ago

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>

misc

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 commented 4 years ago

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
mekanics commented 4 years ago

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?

lubieowoce commented 4 years ago

@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

mekanics commented 4 years ago

@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 😉

claudiulodro commented 3 years ago

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!

anteksiler commented 3 years ago

Any update on this one?

rebeccahum commented 3 years ago

@anteksiler Feel free to open a PR!

leogermani commented 1 year ago

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 commented 1 year ago

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

bjorn2404 commented 5 months ago

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.