wp_set_post_terms
Assign the specified term IDs to a post for a given taxonomy, replacing any existing terms. Use dry-run to preview changes before applying.
Instructions
Set a post's terms for one taxonomy - REPLACES them, never appends.
term_ids is the COMPLETE list the post should end up with (ids from
wp_list_terms); anything not in it is unassigned, and an empty list clears the
taxonomy on that post. Read the post's current terms first if you mean to add one.
post_id comes from wp_find_page / wp_get_content. The write is verified against
what the site reports it stored: WordPress silently drops ids the taxonomy does not
own, and assigning a taxonomy that is not registered for that post's type stores
NOTHING while still answering 200 - both come back as a TermAssignmentMismatch
error rather than a false success. DEFAULTS TO dry_run=true (returns a preview;
writes nothing). Pass dry_run=false to apply. Requires the REST transport. Prod
writes require allow_prod=true.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dry_run | No | ||
| install | Yes | ||
| post_id | Yes | ||
| taxonomy | Yes | ||
| term_ids | Yes | ||
| allow_prod | No |