What is an endpoint for custom post type comments in REST API?

In my react project i am using worpdress as backend and need to use my custom post type events comments also. So as per

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 badges
Add a comment  | 

1 Answer 1

Reset to default 1

Custom 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

相关推荐

  • What is an endpoint for custom post type comments in REST API?

    In my react project i am using worpdress as backend and need to use my custom post type events comments also. So as per

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信