Skip to main content
Glama

wp_get_category

Retrieve a specific WordPress category by its unique ID to access category details and structure for site management and content organization.

Instructions

Retrieves a single category by its ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
idYesThe unique identifier for the category.

Implementation Reference

  • The handler function that executes the wp_get_category tool. It fetches the category by ID from the WordPress client and returns a formatted details string.
    public async handleGetCategory(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
      const { id } = params as { id: number };
      try {
        const category = await client.getCategory(id);
        const content =
          `**Category Details (ID: ${category.id})**\n\n` +
          `- **Name:** ${category.name}\n` +
          `- **Slug:** ${category.slug}\n` +
          `- **Description:** ${category.description || "None"}\n` +
          `- **Post Count:** ${category.count}`;
        return content;
      } catch (_error) {
        throw new Error(`Failed to get category: ${getErrorMessage(_error)}`);
      }
    }
  • Registers the wp_get_category tool in TaxonomyTools.getTools(), including schema (parameters), description, and handler binding.
    {
      name: "wp_get_category",
      description: "Retrieves a single category by its ID.",
      parameters: [
        {
          name: "id",
          type: "number",
          required: true,
          description: "The unique identifier for the category.",
        },
      ],
      handler: this.handleGetCategory.bind(this),
    },

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

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