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

Get all posts from a coauthor using WP REST API

Open gtso86 opened this issue 5 years ago • 4 comments

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()?

gtso86 avatar Jun 03 '19 22:06 gtso86

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 avatar Sep 10 '19 19:09 ckeeney

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

ckeeney avatar Sep 10 '19 20:09 ckeeney

Just for tracking, another request 2783863-zen

htdat avatar Mar 13 '20 06:03 htdat

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.

errotu avatar Apr 29 '21 06:04 errotu