WP rest api: How to get the number of comments

I read the entire Word WP WP rest app app, but I did not find how to limit the number of comments I want. I have tried. http://mywebsite.com/wp-json/posts/999/comments?filter[comments_per_pageapter=1

+5
source share
1 answer

If you can use version 2 of the Rest API, then the endpoint looks something like this:

domain.com/wp-json/wp/v2/comments?post=1&per_page=2 

where the post parameter is the identifier of the message for which you are receiving comments, and per_page is how much is shown. If you need a list of all comments and limit them, then:

 domain.com/wp-json/wp/v2/comments?per_page=2 

You can also add a page parameter to display a different number of calculated comment values:

 domain.com/wp-json/wp/v2/comments?post=1&per_page=2&page=3 

which will return the 5th and 6th comments (page 3 of the comments when there are 2 per page) for the message with identifier 1

0
source

All Articles