Automattic / Co-Authors-Plus

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

Get all posts from a coauthor using WP REST API #680

Open gtso86 opened 5 years ago

gtso86 commented 5 years ago

Hi,

after I add all coauthors in every post now I need retrieve all posts from a specific user, I'm using WP Rest API but only some users (usually only the first author assigned) get posts.

The endpoint I'm using is /wp-json/wp/v2/posts?author=1&_embed=true

For most authors I get no posts.

One possible workaround is create some function to get all posts ids from a specific author, with this info I can use /posts filtering post ids. This could be possible using coauthors_posts_links()?

ckeeney commented 5 years ago

Did you ever find a solution to this? I thought I could pair this plugin with https://wordpress.org/plugins/wp-rest-filter/ but I am not sure what the meta_key and meta_value should be. I've tried various combinations of author and coauthor using IDs and slugs but have not had any luck. I know this is possible PHP code for my own filter but I was trying to be lazier than that.

ckeeney commented 5 years ago

If filtering by author name is acceptable, I managed to get it working using the wp-rest-filter plugin:

wp-json/wp/v2/post?_embed=true&filter[author_name]=Bob%20Marley

htdat commented 4 years ago

Just for tracking, another request 2783863-zen

errotu commented 3 years ago

Might be related to #785? Since CAP is not giving out the co-authors (who are not the first author) to the REST API, you can't retrieve the posts of a co-author via REST, I'd guess.