1
http://example.com/wp-json/wp/v2/posts?author=1

gives me author 1's posts.

http://example.com/wp-json/wp/v2/posts?author=1&author=5

gives me only author 5's posts. Is there any way to get 2 different author's posts with one request?

4
  • Did you try /wp-json/wp/v2/posts?author=1,5
    – birgire
    Commented Jan 20, 2022 at 14:18
  • oh, i didnt try that. Its worked by the way. Thank you! Commented Jan 20, 2022 at 14:44
  • @birgire can you post that as an answer?
    – Tom J Nowell
    Commented Jan 20, 2022 at 15:33
  • Glad to hear it worked. Sure, posted an answer
    – birgire
    Commented Jan 20, 2022 at 16:09

1 Answer 1

0

The author parameter in your request, seems to be mapped to the author__in parameter in WP_Query that runs behind the rest-api call here, where a comma separated input:

/wp-json/wp/v2/posts?author=1,5

is translated to an array( 1,5 ) input for author__in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.