wp_get_page
Retrieve a WordPress page by its ID to view or edit content, with optional full HTML content inclusion for detailed management.
Instructions
Retrieves a single page by its ID, optionally including full content for editing.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site | No | The ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured. | |
| id | Yes | The unique identifier for the page. | |
| include_content | No | If true, includes the full HTML content of the page. Default: false |
Implementation Reference
- src/tools/pages.ts:172-191 (handler)The handler function that executes the wp_get_page tool: retrieves the page by ID using WordPressClient, formats details (title, status, link, date, optional content), and returns as formatted string.public async handleGetPage(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> { const { id, include_content = false } = params as { id: number; include_content?: boolean }; try { const page = await client.getPage(id); let content = `**Page Details (ID: ${page.id})**\n\n` + `- **Title:** ${page.title.rendered}\n` + `- **Status:** ${page.status}\n` + `- **Link:** ${page.link}\n` + `- **Date:** ${new Date(page.date).toLocaleString()}`; if (include_content) { content += `\n\n**Content:**\n\n` + `${page.content.rendered || "(empty)"}`; } return content; } catch (_error) { throw new Error(`Failed to get page: ${getErrorMessage(_error)}`); } }
- src/tools/pages.ts:51-68 (registration)Registers the 'wp_get_page' tool in the PageTools.getTools() array, defining its name, description, input parameters schema, and binding the handler function.{ name: "wp_get_page", description: "Retrieves a single page by its ID, optionally including full content for editing.", parameters: [ { name: "id", type: "number", required: true, description: "The unique identifier for the page.", }, { name: "include_content", type: "boolean", description: "If true, includes the full HTML content of the page. Default: false", }, ], handler: this.handleGetPage.bind(this), },