Resource Information
Method | POST |
---|---|
URL | https://public-api.wordpress.com/rest/v1.1/sites/$site/comments/$comment_ID/delete |
Requires authentication? | Yes |
Method Parameters
Parameter | Type | Description |
---|---|---|
$site | (int|string) | Site ID or domain |
$comment_ID | (int) | The comment ID |
Query Parameters
Parameter | Type | Description |
---|---|---|
context | (string) |
|
http_envelope | (bool) |
|
pretty | (bool) |
|
meta | (string) | Optional. Loads data from the endpoints found in the 'meta' part of the response. Comma-separated list. Example: meta=site,likes |
fields | (string) | Optional. Returns specified fields only. Comma-separated list. Example: fields=ID,title |
callback | (string) | An optional JSONP callback function. |
Response Parameters
Parameter | Type | Description |
---|---|---|
ID | (int) | The comment ID. |
post | (object) | A reference to the comment's post. |
author | (object) | The author of the comment. |
date | (iso 8601 datetime) | The comment's creation time. |
URL | (url) | The full permalink URL to the comment. |
short_URL | (url) | The wp.me short URL. |
content | (html) |
context dependent. |
raw_content | (string) | Raw comment content. |
status | (string) |
|
parent | (object|false) | A reference to the comment's parent, if it has one. |
type | (string) |
|
like_count | (int) | The number of likes for this comment. |
i_like | (bool) | Does the current user like this comment? |
meta | (object) | Meta data |
can_moderate | (bool) | Whether current user can moderate the comment. |
i_replied | (bool) | Has the current user replied to this comment? |
Resource Errors
These are the possible errors returned by this endpoint.
HTTP Code | Error Identifier | Error Message |
---|---|---|
403 | unauthorized | User cannot view post |
403 | unauthorized | User cannot access this private blog. |
403 | unauthorized | User cannot access this restricted blog |
403 | unauthorized | User cannot delete comment |
403 | trash_disabled | Cannot trash comment |
403 | authorization_required | An active access token must be used to comment. |
403 | unauthorized | Comments on this post are closed |
403 | unauthorized | Comments on drafts are not allowed |
403 | unauthorized | User cannot create comments |
403 | unauthorized | User cannot read unapproved comment |
Example
curl \ -H 'authorization: Bearer YOUR_API_TOKEN' \ 'https://public-api.wordpress.com/rest/v1/sites/82974409/comments/$comment_ID/delete'
<?php $options = array ( 'http' => array ( 'ignore_errors' => true, 'method' => 'POST', 'header' => array ( 0 => 'authorization: Bearer YOUR_API_TOKEN', ), ), ); $context = stream_context_create( $options ); $response = file_get_contents( 'https://public-api.wordpress.com/rest/v1/sites/82974409/comments/$comment_ID/delete', false, $context ); $response = json_decode( $response ); ?>
Response
{ "ID": 11448, "post": { "ID": 3, "title": "Hello World (Again)", "type": "post", "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/82974409\/posts\/3" }, "author": { "ID": 0, "login": "", "email": "", "name": "", "first_name": "", "last_name": "", "nice_name": "", "URL": "", "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/?s=96&d=identicon&r=G", "profile_URL": "https:\/\/en.gravatar.com\/d41d8cd98f00b204e9800998ecf8427e", "ip_address": "" }, "date": "2023-09-25T06:00:54+00:00", "URL": "https:\/\/apiexamples.wordpress.com\/2015\/01\/15\/hello-world\/comment-page-1\/#comment-11448", "short_URL": "https:\/\/wp.me\/p5C9qV-3%23comment-11448", "content": "<p>This is a test comment.<\/p>\n", "raw_content": "This is a test comment.", "status": "trash", "parent": false, "type": "comment", "like_count": 0, "i_like": false, "meta": { "links": { "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/82974409\/comments\/11448", "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/82974409\/comments\/11448\/help", "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/82974409", "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/82974409\/posts\/3", "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/82974409\/comments\/11448\/replies\/", "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/82974409\/comments\/11448\/likes\/" } }, "can_moderate": true, "i_replied": false }