Create templates and reuse existing scripts
Use pom_theme_upsert_html_template to create or update an archive, single or feed template. POM Theme owns its rendering and generated assets. The agent supplies HTML and existing asset selections.
Template arguments
| Argument | Required | Meaning |
|---|---|---|
template_type |
Yes | archive, single or feed |
template_name |
Yes | Current or new display name |
template_html |
Yes | Complete replacement markup |
repeater_identifier |
No | Stable template ID; omit to create |
css_stylesheets |
No | Existing named stylesheet IDs or native stylesheet tokens |
js_scripts |
No | Existing script IDs or native feature tokens from the script catalog |
dry_run |
No | JSON true validates and previews without writing |
Template writes require the POM Theme write scope, Allow POM Theme writes and manage_options. Read the template before replacing it and pass its existing name and identifier. Omitting an asset field preserves its current selections; an explicit empty array clears that selection. New templates start with empty selections unless supplied.
HTML is filtered with the installation's KSES post-content rules for every actor, including administrators and super administrators. Script elements and inline handlers are excluded. PHP is refused. Validation also checks known merge tags, balanced conditions and nonempty markup. Read the merge-tag catalog for the selected template type.
Select existing JavaScript
POM AI can reuse the theme's existing JavaScript without creating or changing its code.
- Call
pom_theme_get_script_catalogwithtarget: "template"for templates, ortarget: "content"for pages and posts. - Select the returned
idof each needed script or native feature. The catalog returns names and identifiers, not source code. Content selections omit scripts already configured as global. - For a template, pass those IDs in
js_scriptswhen previewing and savingpom_theme_upsert_html_template. The same rule applies to template rows inpom_theme_configure_content_model. - For a page, post or supported public custom content item, read
pom_theme_get_content_scriptswith itsid. Previewpom_theme_assign_content_scriptswith thatid,js_scriptsanddry_run: true, then apply using the returnedexpected_revision. - Read the saved selection and verify the affected page, including mobile behavior. Clear the relevant page cache when necessary.
Content script assignment also requires the content write gate, the ability to edit that item and edit_theme_options. It updates only the script selection and preserves the item's other theme settings. Pass js_scripts: [] to remove its selections.
Arbitrary URLs, filesystem paths, unregistered identifiers and JavaScript source are refused. Native feature tokens are used exactly as returned, including punctuation. A script that is unavailable or removed must be selected again from the current catalog; the MCP cannot recreate it.
Add CSS and finish the template
Create or update concise named CSS through pom_theme_upsert_custom_css, then select its ID in css_stylesheets. See custom CSS. Unknown stylesheet references are refused too.
Preview the complete template, apply it, read the stored markup back and assign it with pom_theme_assign_template. Updating a template already assigned to a live archive or single view affects that view immediately. A new feed template must be selected by its feed or listing.
Troubleshooting
pom_ai_mcp_script_not_registered: refresh the script catalog and use its exact IDs; do not send URLs or code.pom_ai_mcp_stylesheet_not_registered: create the named stylesheet first and refresh discovery.- Revision conflict on a content assignment: read the item again and review its current selections.
- Removed HTML: the installation's allowed markup policy filtered it; use an allowed element or a native component.
- A tool or write group is unavailable: check the destination, POM Theme activation, scopes and write groups. Delegated multisite page mode has its own smaller catalog.
Related: template assignments, site authoring skill, and security.