In my react project i am using worpdress as backend and need to use my custom post type events
comments also.
So as per the WordPress documentation for comments API i am using an endpoint like this
“/wp/wp-json/wp/v2/comments?events=704
”; so according to this it should display only 704 post-ids comments.
But in my case it returns me all the comments which are posted in the post_type = post
also. See below JSON result of the above API endpoint for custom post type.
Here is a 'post_type' => post
comment's data that returns a correct result.
I have passed this argument in the register_post_type 'show_in_rest'=> true
In my react project i am using worpdress as backend and need to use my custom post type events
comments also.
So as per the WordPress documentation for comments API i am using an endpoint like this
“/wp/wp-json/wp/v2/comments?events=704
”; so according to this it should display only 704 post-ids comments.
But in my case it returns me all the comments which are posted in the post_type = post
also. See below JSON result of the above API endpoint for custom post type.
Here is a 'post_type' => post
comment's data that returns a correct result.
I have passed this argument in the register_post_type 'show_in_rest'=> true
Share Improve this question asked Aug 2, 2019 at 6:29 TMATMA 20012 bronze badges1 Answer
Reset to default 1Custom post types are still posts, so to retrieve comments for a specific post of a custom post type you use the post
argument. From the API reference:
post
Limit result set to comments assigned to specific post IDs.
So:
json/wp/v2/comments?post=704
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745276877a4620094.html
评论列表(0条)