Skip to main content
Glama

Which template renders a URL

get_template_for_url
Read-only

Resolve the exact WordPress template file or block template behind any URL, with hierarchy, customizations, and queried object.

Instructions

Answer "which template file (or block template and template parts) renders this URL, and why?" — the resolved file, the template hierarchy WordPress tried, whether a block template or part has been customised in the Site Editor, the queried object and the conditional tags that were true. A lightweight profile_url. Needs the companion plugin.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlNoPath or full URL on the site./
site_idNoWhich configured WordPress site to act on. Optional — with a single site configured it is used automatically; with several, the default site is used unless you name one. Run list_sites for valid ids.
as_logged_inNoResolve as the logged-in administrator instead of an anonymous visitor.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv2.0.0

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and destructiveHint=false, so the safety profile is covered. The description adds valuable behavioral context: it requires a companion plugin ('Needs the companion plugin'), which is a critical operational constraint. It also discloses the scope of what it resolves (block templates, template parts, Site Editor customizations, conditional tags), which goes beyond the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, information-dense sentence that front-loads the core question, then lists the specific outputs, then positions the tool relative to a sibling, then states the plugin requirement. Every clause earns its place with zero filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read-only diagnostic tool with 100% schema coverage and no output schema, the description covers the essential context: what it resolves, what it reports, and its dependency on a companion plugin. The only minor gap is that it doesn't describe the return format or how the 'why' is presented, but since there's no output schema, a bit more detail on the response shape could help. Still, the description is largely complete for an agent to decide whether to call it.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters (url, site_id, as_logged_in) with clear descriptions. The description adds the overall purpose but doesn't add parameter-specific meaning beyond what the schema provides. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a direct question that defines the tool's exact purpose: 'which template file (or block template and template parts) renders this URL, and why?' It then enumerates the specific outputs (resolved file, template hierarchy, customization status, queried object, conditional tags). This clearly distinguishes it from siblings like get_template (which retrieves a template by ID) and profile_url (which is a broader profiling tool).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context: it's a diagnostic tool for understanding URL-to-template resolution, and explicitly calls itself 'A lightweight profile_url,' which signals when to prefer it over the heavier sibling. However, it doesn't explicitly state when NOT to use it or name alternatives like get_template or list_templates for other template-related queries.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools