Reputation: 3291
I'm using the WP-API plugin as a RESTful API to my Wordpress site. I want the comments associated with a post to return from the /posts/:id
endpoint. The docs indicate that this is possible by passing a withcomments
filter, however I can't get this to work. I've tried the following with no success:
http://climbingnarc.com/wp-json/posts/24001?filter[withcomments]=1
http://climbingnarc.com/wp-json/posts/24001?filter[withcomments]=true
I do know that http://climbingnarc.com/wp-json/posts/24001/comments works, but I don't want to have to make a separate request just for the comment data.
Is there a correct way to use this filter so that comments are returned with the post data?
Upvotes: 2
Views: 2236
Reputation: 83
Try
?_embed=1
in your request; that ought to bring down all embedded data, including comments, alongside the requested post. — K.Adam White
This works for me.
Upvotes: 2
Reputation: 123
Have the same problem. Working on a mobile app and don't want the users to make unnecessary API calls so I decided to make a plugin for.
https://github.com/shahin8r/comments-posts-wp-api
Let me know if you find it useful.
Upvotes: 1
Reputation: 1
This is a bit after the fact, but this worked for me : "/wp-json/posts/{{post id}}/comments/". I'm a big fan of climbing narc! Hope this helps someone
Upvotes: 0
Reputation: 3291
I opened an issue on Github about this and it was marked as Enhancement
, so I'm assuming this just doesn't work at this point
Upvotes: 1