30 days free. No credit card. Full access from the moment you connect your site.

Start free trial

Set Post Language

A post created through the REST API or an import often has no language at all, so it never shows up in the language switcher.

content/set-post-language assigns the language through the multilingual plugin itself.

At a glance

Abilitycontent/set-post-language
ToolsetContent — toolset/content
GroupTranslations › Posts
RequiresPolylang or WPML, active on the site
Capabilitymanage_options
SafetyWrites data
RepeatableIdempotent — running it twice leaves the same result
Ships inAcrossAI Abilities Manager 0.1.0 and later

How it works

Pass the post_id and the language code, such as fr or de.

With Polylang it calls pll_set_post_language(); with WPML it uses the wpml_set_element_language_details action. The result names which one it used.

It only sets the language. To connect the post to its other-language versions, link them as translations.

Input

NameTypeRequiredWhat it is
post_idintegerYesThe post or page ID.
languagestringYesThe language code, as configured in Polylang or WPML.

What comes back

NameTypeWhat it is
driverstringWhich plugin handled the call: Polylang or WPML.
languagestringThe language now assigned.
successbooleanWhether the call completed.
messagestringA one-line summary of what happened, suitable for showing a human.
error_codestringPresent only on failure — a stable machine-readable reason, such as a missing field, a wrong field type or an unmet confirmation.

Example

Ask your assistant:

Set post 88 to French.

It resolves to one call:

{
  "ability": "content/set-post-language",
  "parameters": {
    "post_id": 88,
    "language": "fr"
  }
}

Worth knowing

  • The language code must exist in your Polylang or WPML settings.
  • Setting the same language again changes nothing, so it is idempotent.

Related abilities


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading