WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

XML-RPC WordPress API/Comments

wp.getCommentCount

Retrieve comment count for a specific post.

Added in WordPress 2.5.

Parameters

  • int blog_id
  • string username
  • string password
  • string post_id

Return Values

  • array
    • struct
      • int approved
      • int awaiting_moderation
      • int spam
      • int total_comments

Errors

  • 403

wp.getComment

Retrieve a comment.

Added in WordPress 2.7.

Parameters

  • int blog_id
  • string username
  • string password
  • int comment_id

Return Values

  • struct
    • string comment_id
    • string parent
    • string user_id
    • datetime dateCreated
    • string status
    • string content
    • string link
    • string post_id
    • string post_title
    • string author
    • string author_url
    • string author_email
    • string author_ip
    • string type

Errors

  • 403
  • 404
    • If no comment with that comment_id exists.

wp.getComments

Retrieve list of comments.

Added in WordPress 2.7.

Parameters

  • int blog_id
  • string username
  • string password
  • struct filter
    • int post_id: If empty, retrieves all comments.
    • string status
    • int number
    • int offset

Return Values

Errors

wp.newComment

Create a new comment.

Added in WordPress 2.7.

Parameters

  • int blog_id
  • string username
  • string password
  • int post_id
  • struct comment
    • int comment_parent
    • string content
    • string author
    • string author_url
    • string author_email

Return Values

  • int comment_id

Errors

  • 403
    • If anonymous comments are disallowed and invalid credentials are supplied.
    • If comment does not follow required comment fields configuration.
  • 404
    • If no post with that post_id exists.

Note on Anonymous Comments

By default, the username and password parameters are required. However, if you wish to allow anonymous comments, you can use the xmlrpc_allow_anonymous_comments filter:

add_filter( 'xmlrpc_allow_anonymous_comments', '__return_true' );

In such cases, the username and password parameters can be left as empty strings.

wp.editComment

Edit an existing comment.

Added in WordPress 2.7.

Parameters

  • int blog_id
  • string username
  • string password
  • int comment_id
  • struct comment
    • string status: See #wp.getCommentStatusList. Usually 'hold', 'approve', or 'spam'.
    • datetime date_created_gmt
    • string content
    • string author
    • string author_url
    • string author_email

Return Values

  • boolean true

Errors

  • 401
    • If status is not a valid comment status.
  • 403
    • If the user does not have the moderate_comments cap.
    • If the user does not have permission to edit this comment.
  • 404
    • If no comment with that comment_id exists.

wp.deleteComment

Remove an existing comment.

Added in WordPress 2.7.

Parameters

  • int blog_id
  • string username
  • string password
  • int comment_id

Return Values

  • boolean true

Errors

  • 403
    • If the user does not have the moderate_comments cap.
    • If the user does not have permission to edit this comment.
  • 404
    • If no comment with that comment_id exists.

wp.getCommentStatusList

Retrieve list of comment statuses.

Added in WordPress 2.7.

Parameters

  • int blog_id
  • string username
  • string password

Return Values

  • array
    • struct
      • string (key): status value
      • string (value): status description