Assign terms to content
assign_terms_to_contentAssign taxonomy terms to WordPress content by ID or name, auto-creating missing terms. Replace, add, or remove terms with a simple mode option.
Instructions
Assign taxonomy terms to any content item. Terms may be given as IDs or as names — names that do not exist are created for you. By default this replaces the item's terms in that taxonomy; pass mode: "add" to keep the existing ones, or "remove" to detach.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | replace: these become the only terms. add: keep existing and add these. remove: detach these. | replace |
| type | No | Content type of that ID. | post |
| terms | Yes | Term IDs, or names — unknown names are created. | |
| site_id | No | Which 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. | |
| taxonomy | Yes | Taxonomy to assign within (category, post_tag, or a custom one). | |
| content_id | Yes | The content item to modify. | |
| create_missing | No | Create terms given by name that do not exist yet. |