Skip to content

Post Comments

corsacca edited this page Apr 14, 2020 · 9 revisions

Get comments

Get https://example.com/wp-json/dt-posts/v2/{post_type}/{post_id}/comments

Parameters

  • number (int) optional. How many comments to return
  • offset (int) optional. How many comments to skip (for pagination)

Returns

[ 
   comments: (array) An array of comments.
   total: (int) the number of comment in total
]

Create a comment

POST https://example.com/wp-json/dt/v2/{post_type}/{post_id}/comments

Parameters

  • comment (string) the body of the comment.
  • date (string) optional. format "Y-m-d H:i:s"
  • comment_type (string) optional. The comment type. Default: 'comment'

Query params: add ?silent=true to disable notifications

@mentions Mention are used to make sure a user sees a comment and gets a notification. This example @mentions user with id 46 and will display bob as the name of the user.

{
	"comment": "@[bob](46) this is a mention notification"
}

Returns

(object) The default wordpress comment. See https://codex.wordpress.org/Function_Reference/get_comment

Update a comment

POST https://example.com/wp-json/dt/v2/{post_type}/{post_id}/comments/{comment_id}

Parameters

  • comment (string) the body of the comment.

Returns

(object) The default wordpress comment. See https://codex.wordpress.org/Function_Reference/get_comment

Delete a comment

DELETE https://example.com/wp-json/dt/v2/{post_type}/{post_id}/comments/{comment_id}

Returns

(bool) true if the contact was deleted