Skip to main content
Glama

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
NameRequiredDescriptionDefault
post_idYes
forceNo

Implementation Reference

  • 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)
  • 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, }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gaupoit/wordpress-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server