Reputation: 1854
I read all the Wordpress WP rest api document but i did not find how to limit the numbers of comments i want. I tryed. http://mywebsite.com/wp-json/posts/999/comments?filter[comments_per_page]=1
Upvotes: 5
Views: 3588
Reputation: 21713
If you're able to use version 2 of the Rest API, then the endpoint is something like the following:
domain.com/wp-json/wp/v2/comments?post=1&per_page=2
where the post
parameter is the ID of the post for which you're retrieving the comments and per_page
is how many to show. If you want a list of all comments, and limit them, then:
domain.com/wp-json/wp/v2/comments?per_page=2
You can also append a page parameter to show a different paged value of comments thus:
domain.com/wp-json/wp/v2/comments?post=1&per_page=2&page=3
which would return the 5th and 6th comments (page 3 of comments when there are 2 per page) for the post with an ID of 1
Upvotes: 3