Skip to main content
Glama

update-category

Modify a WordPress category by updating its name, description, slug, parent ID, or meta fields using site URL, credentials, and category ID for precise adjustments.

Instructions

Update an existing WordPress category

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryIdYesID of the category to update
descriptionNoNew HTML description of the term
metaNoNew meta fields
nameNoNew HTML title for the term
parentNoNew parent term ID
passwordYesWordPress application password
siteUrlYesWordPress site URL
slugNoNew alphanumeric identifier for the term
usernameYesWordPress username

Implementation Reference

  • The async handler function for the 'update-category' tool. It constructs update data from input parameters, validates that at least one field is provided, makes a POST request to the WordPress REST API /categories/{categoryId} endpoint using makeWPRequest, and returns success or error message.
    async ({ siteUrl, username, password, categoryId, name, description, slug, parent, meta, }) => { try { const categoryData: Record<string, any> = {}; if (name) categoryData.name = name; if (description) categoryData.description = description; if (slug) categoryData.slug = slug; if (parent) categoryData.parent = parent; if (meta) categoryData.meta = meta; if (Object.keys(categoryData).length === 0) { return { content: [ { type: "text", text: "No update data provided. Please specify at least one field to update.", }, ], }; } const category = await makeWPRequest<WPCategory>({ siteUrl, endpoint: `categories/${categoryId}`, method: "POST", auth: { username, password }, data: categoryData }); return { content: [ { type: "text", text: `Successfully updated category:\nID: ${category.id}\nName: ${category.name || name || "Unchanged"}\nSlug: ${category.slug || slug || "Unchanged"}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error updating category: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
  • Zod input schema defining parameters for the update-category tool: required siteUrl, username, password, categoryId; optional name, description, slug, parent, meta.
    { siteUrl: z.string().url().describe("WordPress site URL"), username: z.string().describe("WordPress username"), password: z.string().describe("WordPress application password"), categoryId: z.number().describe("ID of the category to update"), name: z.string().optional().describe("New HTML title for the term"), description: z.string().optional().describe("New HTML description of the term"), slug: z.string().optional().describe("New alphanumeric identifier for the term"), parent: z.number().optional().describe("New parent term ID"), meta: z.record(z.any()).optional().describe("New meta fields"), },
  • src/index.ts:1985-2057 (registration)
    The server.tool() call that registers the 'update-category' MCP tool with name, description, input schema, and inline handler function.
    server.tool( "update-category", "Update an existing WordPress category", { siteUrl: z.string().url().describe("WordPress site URL"), username: z.string().describe("WordPress username"), password: z.string().describe("WordPress application password"), categoryId: z.number().describe("ID of the category to update"), name: z.string().optional().describe("New HTML title for the term"), description: z.string().optional().describe("New HTML description of the term"), slug: z.string().optional().describe("New alphanumeric identifier for the term"), parent: z.number().optional().describe("New parent term ID"), meta: z.record(z.any()).optional().describe("New meta fields"), }, async ({ siteUrl, username, password, categoryId, name, description, slug, parent, meta, }) => { try { const categoryData: Record<string, any> = {}; if (name) categoryData.name = name; if (description) categoryData.description = description; if (slug) categoryData.slug = slug; if (parent) categoryData.parent = parent; if (meta) categoryData.meta = meta; if (Object.keys(categoryData).length === 0) { return { content: [ { type: "text", text: "No update data provided. Please specify at least one field to update.", }, ], }; } const category = await makeWPRequest<WPCategory>({ siteUrl, endpoint: `categories/${categoryId}`, method: "POST", auth: { username, password }, data: categoryData }); return { content: [ { type: "text", text: `Successfully updated category:\nID: ${category.id}\nName: ${category.name || name || "Unchanged"}\nSlug: ${category.slug || slug || "Unchanged"}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error updating category: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } );

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/prathammanocha/wordpress-mcp-server'

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