Settings REST API

The Settings REST API is included with Polylang. This API provides programmatic access to manage Polylang settings through HTTP endpoints. It allows to retrieve and update various configuration options that control how Polylang handles multilingual functionality in a WordPress installation. All endpoints are accessible via /wp-json/pll/v1/settings.

Table of Contents

Get Settings

Retrieves all current Polylang settings.

GET /wp-json/pll/v1/settings

Response Schema

PropertyTypeDefaultDescription
force_langinteger1Determines how the current language is defined. Values: 1, 2, or 3.
domainsobject{}Domains used when language is set from different domains. Keys are language slugs that must match the pattern ^[a-z][a-z0-9_-]*$. Values are URIs.
hide_defaultbooleantrueWhether to remove language code in URL for default language.
rewritebooleantrueWhether to remove /language/ in pretty permalinks.
redirect_langbooleanfalseWhether to remove page name/ID from front page URL.
browserbooleanfalseWhether to detect preferred browser language on front page.
media_supportbooleanfalseWhether to enable media translation.
post_typesarray[]List of post types to translate.
taxonomiesarray[]List of taxonomies to translate.
syncarray[]List of data to synchronize between translations.
default_langstring""Slug of the default language (must match pattern ^[a-z][a-z0-9_-]*$).
nav_menusobject{}Translated navigation menus configuration for each theme.
language_taxonomiesarray[]List of language taxonomies used for custom DB tables.
media*object{"duplicate": false}Settings for media duplication across languages.
machine_translation_enabled*booleanfalseWhether machine translation is enabled.
machine_translation_services*object{"deepl": []}Settings for machine translation services (DeepL API key and formality).
versionstring""Current Polylang version (read-only).
previous_versionstring""Previous Polylang version (read-only).
first_activationinteger1738660878Timestamp of first Polylang activation (read-only).

* Pro version only

Update Settings

Updates Polylang settings. Supports POST, PUT, and PATCH methods.

POST/PUT/PATCH /wp-json/pll/v1/settings

Parameters

ParameterTypeRequiredDescription
force_langintegerNoDetermines how the current language is defined. Values: 1, 2, or 3.
domainsobjectNoDomains used when language is set from different domains. Keys are language slugs that must match the pattern ^[a-z][a-z0-9_-]*$. Values are URIs.
hide_defaultbooleanNoWhether to remove language code in URL for default language.
rewritebooleanNoWhether to remove /language/ in pretty permalinks.
redirect_langbooleanNoWhether to remove page name/ID from front page URL.
browserbooleanNoWhether to detect preferred browser language on front page.
media_supportbooleanNoWhether to enable media translation.
post_typesarrayNoList of post types to translate.
taxonomiesarrayNoList of taxonomies to translate.
syncarrayNoList of data to synchronize between translations.
default_langstringNoSlug of the default language (must match pattern ^[a-z][a-z0-9_-]*$).
nav_menusobjectNoTranslated navigation menus configuration for each theme.
language_taxonomiesarrayNoList of language taxonomies used for custom DB tables.
media*objectNoSettings for media duplication. Contains duplicate boolean property.
machine_translation_enabled*booleanNoWhether to enable machine translation.
machine_translation_services*objectNoSettings for translation services. Contains DeepL configuration with API key and formality settings.

* Pro version only

Sync Options

The sync parameter accepts an array of the following values:

  • taxonomies
  • post_meta
  • comment_status
  • ping_status
  • sticky_posts
  • post_date
  • post_format
  • post_parent
  • _wp_page_template
  • menu_order
  • _thumbnail_id

Machine Translation Service Options (Pro)

The machine_translation_services parameter accepts a DeepL configuration object with the following properties:

  • api_key: string – DeepL API key.
  • formality: string – Translation formality level. Values: "default", "prefer_more", "prefer_less".

Example Request

POST /wp-json/pll/v1/settings
{
  "force_lang": 1,
  "hide_default": true,
  "browser": false,
  "post_types": ["post", "page"],
  "sync": ["post_meta", "taxonomies"],
  "default_lang": "en",
  "media": {                           /* Pro */
    "duplicate": true
  },
  "machine_translation_enabled": true, /* Pro */
  "machine_translation_services": {    /* Pro */
    "deepl": {
      "api_key": "your-api-key",
      "formality": "prefer_more"
    }
  }
}

Response Properties

The API returns an object containing all settings, including read-only properties.

General Remarks

  • All endpoints support batch requests through the v1 batch API.
  • Update endpoint requires authentication with a user that has the manage_options capability.
  • Default values are provided for all settings if not specified.
  • The API enforces strict validation of parameter types and formats.
  • The complete API schema is discoverable on OPTIONS /wp-json/pll/v1/settings endpoint. This provides detailed information about available endpoints, methods, parameters, and their constraints.