wp_delete_post
Remove WordPress posts by ID, either moving them to trash or permanently deleting them based on the force parameter setting.
Instructions
Delete a WordPress post.
Args:
post_id: The ID of the post to delete.
force: If False (default), moves to trash. If True, permanently deletes.
Returns:
Confirmation with id, deleted status, and previous post info.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| post_id | Yes | ||
| force | No |
Implementation Reference
- src/wordpress_mcp/server.py:167-179 (handler)The main handler function for the 'wp_delete_post' tool. It is decorated with @mcp.tool() which also serves as the registration mechanism in FastMCP. The function retrieves the WordPress client and calls its delete_post method.@mcp.tool() def wp_delete_post(post_id: int, force: bool = False) -> dict: """Delete a WordPress post. Args: post_id: The ID of the post to delete. force: If False (default), moves to trash. If True, permanently deletes. Returns: Confirmation with id, deleted status, and previous post info. """ client = get_client() return client.delete_post(post_id=post_id, force=force)
- src/wordpress_mcp/client.py:257-269 (helper)The supporting method in WordPressClient that performs the actual deletion via WordPress REST API using the _delete helper, handling the force parameter and formatting the response.def delete_post(self, post_id: int, force: bool = False) -> dict: """Delete a post. If force=False, moves to trash. If force=True, permanently deletes.""" params = {"force": force} result = self._delete(f"posts/{post_id}", params) return { "id": result.get("id", post_id), "deleted": True, "previous": { "title": result.get("title", {}).get("rendered", ""), "status": result.get("status", ""), } if "title" in result else None, }