Co-Authors-Plus
Co-Authors-Plus copied to clipboard
Get all posts from a coauthor using WP REST API
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()
?
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.
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
Just for tracking, another request 2783863-zen
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.