### Get All Settings
Source: https://polylang.pro/documentation/support/developers/polylang-cli
Retrieve all Polylang settings. The output format defaults to a table.
```bash
wp pll setting get
```
--------------------------------
### Get Polylang Settings via REST API
Source: https://polylang.pro/documentation/support/developers/settings-rest-api
Use this endpoint to retrieve all current Polylang settings. No specific setup is required beyond having Polylang installed.
```http
GET /wp-json/pll/v1/settings
```
--------------------------------
### Get Specific Settings
Source: https://polylang.pro/documentation/support/developers/polylang-cli
Retrieve specific Polylang settings by providing a comma-separated list of setting keys.
```bash
wp pll setting get --keys=media_support,force_lang
```
--------------------------------
### Get Polylang Settings
Source: https://polylang.pro/documentation/support/developers/settings-rest-api
Retrieves all current Polylang settings.
```APIDOC
## GET /wp-json/pll/v1/settings
### Description
Retrieves all current Polylang settings.
### Method
GET
### Endpoint
/wp-json/pll/v1/settings
### Response
#### Success Response (200)
- **force_lang** (integer) - Determines how the current language is defined. Values: 1, 2, or 3.
- **domains** (object) - 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_default** (boolean) - Whether to remove language code in URL for default language.
- **rewrite** (boolean) - Whether to remove `/language/` in pretty permalinks.
- **redirect_lang** (boolean) - Whether to remove page name/ID from front page URL.
- **browser** (boolean) - Whether to detect preferred browser language on front page.
- **media_support** (boolean) - Whether to enable media translation.
- **post_types** (array) - List of post types to translate.
- **taxonomies** (array) - List of taxonomies to translate.
- **sync** (array) - List of data to synchronize between translations.
- **default_lang** (string) - Slug of the default language (must match pattern `^[a-z][a-z0-9_-]*$`).
- **nav_menus** (object) - Translated navigation menus configuration for each theme.
- **language_taxonomies** (array) - List of language taxonomies used for custom DB tables.
- **media** (object) - Settings for media duplication across languages. (Pro version only)
- **machine_translation_enabled** (boolean) - Whether machine translation is enabled. (Pro version only)
- **machine_translation_services** (object) - Settings for machine translation services (DeepL API key and formality). (Pro version only)
- **version** (string) - Current Polylang version (read-only).
- **previous_version** (string) - Previous Polylang version (read-only).
- **first_activation** (integer) - Timestamp of first Polylang activation (read-only).
#### Response Example
{
"force_lang": 1,
"domains": {},
"hide_default": true,
"rewrite": true,
"redirect_lang": false,
"browser": false,
"media_support": false,
"post_types": [],
"taxonomies": [],
"sync": [],
"default_lang": "",
"nav_menus": {},
"language_taxonomies": [],
"media": {"duplicate": false},
"machine_translation_enabled": false,
"machine_translation_services": {"deepl": []},
"version": "3.3.1",
"previous_version": "3.3.0",
"first_activation": 1738660878
}
```
--------------------------------
### Get All Posts
Source: https://polylang.pro/documentation/support/developers/rest-api
Without the 'lang' argument, this request will return posts in all available languages.
```http
GET /wp/v2/posts
```
--------------------------------
### List All Languages (GET)
Source: https://polylang.pro/documentation/support/developers/languages-rest-api
Retrieves a list of all configured languages. Requires `manage_options` capability when `context` is set to `edit`. Deactivated languages are also included.
```http
GET /wp-json/pll/v1/languages
```
--------------------------------
### Get Home URL by Language
Source: https://polylang.pro/documentation/support/developers/function-reference
Retrieves the homepage URL for a specified language. Defaults to the current language on the frontend.
```php
pll_home_url( $slug );
```
--------------------------------
### pll_home_url
Source: https://polylang.pro/documentation/support/developers/function-reference
Gets the home URL for a specific language.
```APIDOC
## pll_home_url
### Description
Retrieves the home URL of the WordPress installation, optionally filtered by a specific language.
### Function Signature
`pll_home_url( string $lang = null )`
### Parameters
#### lang (string) - Optional
The language code (e.g., 'en', 'fr') for which to get the home URL. If null, the default home URL is returned.
### Returns
(string) The home URL for the specified language.
```
--------------------------------
### pll_languages_list
Source: https://polylang.pro/documentation/support/developers/function-reference
Gets a list of all languages.
```APIDOC
## pll_languages_list
### Description
Retrieves an array containing information about all languages configured in Polylang.
### Function Signature
`pll_languages_list( array $args = array() )`
### Parameters
#### args (array) - Optional
An array of arguments to filter or modify the returned list. Possible arguments include:
- 'hide_if_no_translation' (bool): If true, languages without any translations will be hidden. Default false.
- 'raw' (bool): If true, returns raw language objects. Default false.
### Returns
(array) An array of language objects or arrays, depending on the 'raw' argument.
```
--------------------------------
### Get Home URL using icl_get_home_url
Source: https://polylang.pro/documentation/support/developers/wpml-api
Retrieves the home page URL in the active language. The Polylang equivalent is pll_home_url.
```php
icl_get_home_url();
```
--------------------------------
### Get Current Language
Source: https://polylang.pro/documentation/support/developers/function-reference
Retrieves the current language's name, locale, or slug. Defaults to slug.
```php
pll_current_language( $value );
```
--------------------------------
### Set Custom Flag URL and Dimensions
Source: https://polylang.pro/documentation/support/developers/filter-reference
Customize flag URLs and dimensions for frontend display. This example sets a custom SVG flag URL and specifies width and height.
```php
add_filter( 'pll_custom_flag', 'pll_custom_flag', 10, 2 );
function pll_custom_flag( $flag, $code ) {
$flag['url'] = "http://mysite.com/wordpress/wp-content/polylang/{$code}.svg";
$flag['width'] = 32;
$flag['height'] = 22;
return $flag;
}
```
--------------------------------
### Get Default Language
Source: https://polylang.pro/documentation/support/developers/function-reference
Retrieves the default language's name, locale, or slug. Defaults to slug.
```php
pll_default_language( $value );
```
--------------------------------
### Example Custom Gutenberg Block HTML Structure
Source: https://polylang.pro/documentation/support/developers/how-to-make-a-custom-gutenberg-block-multilingual
This HTML structure represents a custom Gutenberg block with Polylang Pro specific comments indicating translatable attributes and content. Ensure your block's translatable parts are within these comments or defined by XPaths.
```html
My Awesome Image Caption
```
--------------------------------
### Get List of Languages
Source: https://polylang.pro/documentation/support/developers/function-reference
Retrieve a list of all configured languages in Polylang. An optional array of arguments can be passed to filter the results, such as hiding empty languages or specifying the fields to return.
```php
pll_languages_list( $args );
```
--------------------------------
### Get Raw Language Data
Source: https://polylang.pro/documentation/support/developers/function-reference
Retrieves an array of language data for creating a custom language switcher. Each element in the array contains details like language ID, slug, name, URL, flag, and translation status.
```php
$translations = pll_the_languages( array( 'raw' => 1 ) );
```
--------------------------------
### Get a single language by ID or slug with Polylang CLI
Source: https://polylang.pro/documentation/support/developers/polylang-cli
Fetch details for a specific language using its term ID or slug. Similar to the list command, you can specify fields and output format.
```bash
wp pll language get en
```
```bash
wp pll language get 1
```
--------------------------------
### pll_get_term_language
Source: https://polylang.pro/documentation/support/developers/function-reference
Gets the language of a term.
```APIDOC
## pll_get_term_language
### Description
Retrieves the language information for a given term (category, tag, etc.).
### Function Signature
`pll_get_term_language( int $term_id = null, string $field = 'locale' )`
### Parameters
#### term_id (int) - Optional
The ID of the term. If null, the current term in the loop is used.
#### field (string) - Optional
The specific field to retrieve from the language object. Defaults to 'locale'. Other possible values include 'slug', 'name', 'full_name', 'locale', 'woeid', 'flag', 'url'.
### Returns
(string|array|bool) The value of the requested field for the term's language, an array of all language information if no field is specified, or false if the term is not translated or language information cannot be determined.
```
--------------------------------
### Set Domains Setting with JSON
Source: https://polylang.pro/documentation/support/developers/polylang-cli
Configure language domains using a JSON string. The format should be a map where keys are language codes and values are domain names.
```bash
wp pll setting set domains '{"fr":"example.fr"}'
```
--------------------------------
### Set Media Support Setting
Source: https://polylang.pro/documentation/support/developers/polylang-cli
Enable or disable media support in Polylang. Use 'true' or 'false' for boolean settings.
```bash
wp pll setting set media_support true
```
```bash
wp pll setting set media_duplicate true
```
--------------------------------
### pll_get_post_language
Source: https://polylang.pro/documentation/support/developers/function-reference
Gets the language of a post.
```APIDOC
## pll_get_post_language
### Description
Retrieves the language information for a given post.
### Function Signature
`pll_get_post_language( int $post_id = null, string $field = 'locale' )`
### Parameters
#### post_id (int) - Optional
The ID of the post. If null, the current post in the loop is used.
#### field (string) - Optional
The specific field to retrieve from the language object. Defaults to 'locale'. Other possible values include 'slug', 'name', 'full_name', 'locale', 'woeid', 'flag', 'url'.
### Returns
(string|array|bool) The value of the requested field for the post's language, an array of all language information if no field is specified, or false if the post is not translated or language information cannot be determined.
```
--------------------------------
### Initial wpml-config.xml for Serialized Options
Source: https://polylang.pro/documentation/support/developers/how-to-translate-options-with-a-wpml-config-xml-file
Use this basic structure to begin defining serialized options within the admin-texts section of your wpml-config.xml file.
```xml
```
--------------------------------
### pll_get_term_translations
Source: https://polylang.pro/documentation/support/developers/function-reference
Gets all translations for a given term.
```APIDOC
## pll_get_term_translations
### Description
Retrieves an array of all translations for a given term (category, tag, etc.).
### Function Signature
`pll_get_term_translations( int $term_id )`
### Parameters
#### term_id (int) - Required
The ID of the term for which to retrieve translations.
### Returns
(array|bool) An associative array where keys are language codes and values are the translated term IDs, or false if the term is not translatable or has no translations.
```
--------------------------------
### Reset All Settings (with confirmation)
Source: https://polylang.pro/documentation/support/developers/polylang-cli
Use this command to reset all Polylang Pro settings. It will prompt for confirmation before proceeding.
```bash
wp pll setting reset
```
--------------------------------
### pll_get_post_translations
Source: https://polylang.pro/documentation/support/developers/function-reference
Gets all translations for a given post.
```APIDOC
## pll_get_post_translations
### Description
Retrieves an array of all translations for a given post.
### Function Signature
`pll_get_post_translations( int $post_id )`
### Parameters
#### post_id (int) - Required
The ID of the post for which to retrieve translations.
### Returns
(array|bool) An associative array where keys are language codes and values are the translated post IDs, or false if the post is not translatable or has no translations.
```
--------------------------------
### pll_default_language
Source: https://polylang.pro/documentation/support/developers/function-reference
Gets the default language information.
```APIDOC
## pll_default_language
### Description
Retrieves information about the default language of the site.
### Function Signature
`pll_default_language( string $field = 'locale' )`
### Parameters
#### field (string) - Optional
The specific field to retrieve from the language object. Defaults to 'locale'. Other possible values include 'slug', 'name', 'full_name', 'locale', 'woeid', 'flag', 'url'.
### Returns
(string|array) The value of the requested field for the default language, or an array containing all language information if no field is specified.
```
--------------------------------
### Translate Emails Using Locale Switching
Source: https://polylang.pro/documentation/support/developers/how-to-translate-emails
This sequence demonstrates the recommended steps for translating emails. Ensure theme and plugin translations are loaded after switching locales.
```php
/* Step 1: Get the locale the email must be sent */
$locale = get_user_locale();
/* Step 2: Call switch_to_locale() */
switch_to_locale( $locale );
/* Step 3: Call load_plugin_textdomain to load your plugin’s translations */
load_plugin_textdomain( 'my-text-domain', false, 'my-text-domain/languages' );
/* Step 4: Construct and send the email */
// ... email construction and sending using __()
/* Step 5: Call restore_previous_locale() */
restore_previous_locale();
/* Step 6: Call load_plugin_textdomain to load your plugin’s translations */
load_plugin_textdomain( 'my-text-domain', false, 'my-text-domain/languages' );
```
--------------------------------
### wpml-config.xml with Specific Serialized Keys
Source: https://polylang.pro/documentation/support/developers/how-to-translate-options-with-a-wpml-config-xml-file
After identifying sub-keys, add them within the parent key in wpml-config.xml to enable translation for specific serialized fields.
```xml
```
--------------------------------
### pll_current_language
Source: https://polylang.pro/documentation/support/developers/function-reference
Gets the current language information.
```APIDOC
## pll_current_language
### Description
Retrieves information about the currently active language.
### Function Signature
`pll_current_language( string $field = 'locale' )`
### Parameters
#### field (string) - Optional
The specific field to retrieve from the language object. Defaults to 'locale'. Other possible values include 'slug', 'name', 'full_name', 'locale', 'woeid', 'flag', 'url'.
### Returns
(string|array) The value of the requested field for the current language, or an array containing all language information if no field is specified.
```
--------------------------------
### Enable WPML Compatibility API
Source: https://polylang.pro/documentation/support/developers/php-constants
PLL_WPML_COMPAT determines whether the WPML compatibility API is loaded. Defaults to true.
```php
define('PLL_WPML_COMPAT', false);
```
--------------------------------
### Set Translatable Post Types Setting
Source: https://polylang.pro/documentation/support/developers/polylang-cli
Define which post types are translatable by providing a JSON array of post type names.
```bash
wp pll setting set post_types '["custom_post_type","another_custom_post_type"]'
```
--------------------------------
### pll_get_term
Source: https://polylang.pro/documentation/support/developers/function-reference
Gets the translated term ID for a given term ID and language.
```APIDOC
## pll_get_term
### Description
Retrieves the ID of a translated term (category, tag, etc.) given a term ID and the target language.
### Function Signature
`pll_get_term( int $term_id, string $lang = null )`
### Parameters
#### term_id (int) - Required
The ID of the term for which to find the translation.
#### lang (string) - Optional
The language code (e.g., 'en', 'fr') of the desired translation. If null, the current language is used.
### Returns
(int|null) The ID of the translated term, or null if no translation is found.
```
--------------------------------
### Reset Specific Settings
Source: https://polylang.pro/documentation/support/developers/polylang-cli
Restore one or more specified Polylang settings to their default values. Use a comma-separated list for the --keys option.
```bash
wp pll setting reset --keys=media_support,force_lang
```
--------------------------------
### pll_get_post
Source: https://polylang.pro/documentation/support/developers/function-reference
Gets the translated post ID for a given post ID and language.
```APIDOC
## pll_get_post
### Description
Retrieves the ID of a translated post given a post ID and the target language.
### Function Signature
`pll_get_post( int $post_id, string $lang = null )`
### Parameters
#### post_id (int) - Required
The ID of the post for which to find the translation.
#### lang (string) - Optional
The language code (e.g., 'en', 'fr') of the desired translation. If null, the current language is used.
### Returns
(int|null) The ID of the translated post, or null if no translation is found.
```
--------------------------------
### Enable Third-Party Plugin Compatibility
Source: https://polylang.pro/documentation/support/developers/php-constants
Set PLL_PLUGINS_COMPAT to true to load support for various third-party plugins like Yoast SEO and Jetpack. Defaults to true.
```php
define('PLL_PLUGINS_COMPAT', false);
```
--------------------------------
### Reset All Settings (without confirmation)
Source: https://polylang.pro/documentation/support/developers/polylang-cli
Execute this command to reset all Polylang Pro settings without a confirmation prompt. This is useful for scripting and automated processes.
```bash
wp pll setting reset --yes
```
--------------------------------
### Merging wpml-config.xml with Existing Custom Types
Source: https://polylang.pro/documentation/support/developers/how-to-translate-options-with-a-wpml-config-xml-file
Combine new admin-text configurations with existing custom-type translations in a single wpml-config.xml file.
```xml
et_pb_layout
```
--------------------------------
### Get Post Translation
Source: https://polylang.pro/documentation/support/developers/function-reference
Retrieves the ID of a translated post or page. Requires the post ID and optionally a language slug.
```php
pll_get_post( $post_id, $slug );
```
--------------------------------
### Add New Language (POST)
Source: https://polylang.pro/documentation/support/developers/languages-rest-api
Creates a new language with specified parameters. Default values for name, slug, RTL, and flag code are used if not provided. The `locale` parameter is mandatory.
```http
POST /wp-json/pll/v1/languages
```
```json
{
"locale": "fr_FR",
"name": "Français",
"slug": "fr",
"flag_code": "fr"
}
```
--------------------------------
### Get Term Translation
Source: https://polylang.pro/documentation/support/developers/function-reference
Retrieves the ID of a translated term (category or tag). Requires the term ID and optionally a language slug.
```php
pll_get_term( $term_id, $slug );
```
--------------------------------
### List all configured languages with Polylang CLI
Source: https://polylang.pro/documentation/support/developers/polylang-cli
Retrieve a list of all languages configured in Polylang. You can filter by fields like slug and specify the output format (table, JSON, YAML, CSV).
```bash
wp pll language list
```
```bash
wp pll language list --slug=en,fr,es
```
```bash
wp pll language list --fields=name,slug,locale
```
--------------------------------
### Add Domain to Map Setting
Source: https://polylang.pro/documentation/support/developers/polylang-cli
Add a new key/value pair to the domains map setting. The first argument is the key (language code), and the second is the value (domain name).
```bash
wp pll setting add domains en example.com
```
--------------------------------
### Get All Languages
Source: https://polylang.pro/documentation/support/developers/rest-api
An additional endpoint to retrieve a list of all configured languages in Polylang, including their names, codes, locales, and associated URLs.
```APIDOC
## GET /pll/v1/languages
### Description
Retrieves a list of all languages configured in Polylang.
### Method
GET
### Endpoint
/pll/v1/languages
### Response
#### Success Response (200)
- **name** (string) - The native name of the language.
- **slug** (string) - The language code (e.g., 'en', 'fr').
- **locale** (string) - The WordPress locale for the language.
- **flag_url** (string) - The URL of the language's flag icon.
- **home_url** (string) - The URL of the site's homepage in this language.
- **page_on_front** (integer) - The ID of the static front page for this language, if applicable.
- **page_for_posts** (integer) - The ID of the page for posts for this language, if applicable.
### Response Example
```json
{
"name": "English",
"slug": "en",
"locale": "en_US",
"flag_url": "http://example.com/wp-content/plugins/polylang/flags/en.png",
"home_url": "http://example.com/",
"page_on_front": 1,
"page_for_posts": 2
}
```
```
--------------------------------
### Get Translated String using icl_t
Source: https://polylang.pro/documentation/support/developers/wpml-api
Retrieves the translated string for a given context and name. An optional string parameter can be provided if the translation is not found.
```php
icl_t($context, $name, $string);
```
--------------------------------
### Create a new language with Polylang CLI
Source: https://polylang.pro/documentation/support/developers/polylang-cli
Use this command to add a new language. You can specify the locale, name, slug, flag, text direction, display order, and whether to skip creating a default category.
```bash
wp pll language create en_US
```
```bash
wp pll language create en_US --name="English" --slug=en
```
```bash
wp pll language create fr_FR --name="Français" --slug=fr --flag=fr --order=1
```
```bash
wp pll language create ar --dir=rtl --order=2
```
```bash
wp pll language create es_ES --name="Español" --slug=es --skip-default-cat
```
--------------------------------
### Get Posts in a Specific Language
Source: https://polylang.pro/documentation/support/developers/rest-api
Use the 'lang' argument to filter posts by language. This is applicable to posts and terms across any post type or taxonomy.
```http
GET /wp/v2/posts?lang=fr
```
--------------------------------
### Assigning Language and Translations to a Post
Source: https://polylang.pro/documentation/support/developers/rest-api
Shows how to assign a language to a post and link it with its translations using a POST request. Ensure the translation already exists in its respective language.
```APIDOC
## POST /wp/v2/posts/{id}
### Description
Assigns a language to a specific post and establishes links to its translations.
### Method
POST
### Endpoint
/wp/v2/posts/{id}
#### Path Parameters
- **id** (integer) - Required - The ID of the post to update.
#### Query Parameters
- **lang** (string) - Required - The language code to assign to the post (e.g., 'fr').
- **translations[language_code]** (integer) - Required - Links the post to its translation. The key is the language code of the translation (e.g., 'en'), and the value is the ID of the translated post.
### Request Example
```
POST /wp/v2/posts/3376?lang=fr&translations[en]=3374
```
*Note: The post with ID 3374 must already exist and be set to the 'en' language.*
```
--------------------------------
### Add Simple Option to wpml-config.xml
Source: https://polylang.pro/documentation/support/developers/how-to-translate-options-with-a-wpml-config-xml-file
Use this structure to add a simple, non-serialized option to your wpml-config.xml file for translation. The 'name' attribute should match the option name found in your database.
```xml
```
--------------------------------
### Add 'x-default' hreflang Attribute
Source: https://polylang.pro/documentation/support/developers/filter-reference
This filter allows modification of hreflang attributes. This example adds the English URL as the 'x-default' hreflang attribute on all pages.
```php
// Adds English as 'x-default' on all pages:
add_filter( 'pll_rel_hreflang_attributes', function( $hreflangs ) {
$hreflangs['x-default'] = $hreflangs['en'];
return $hreflangs; // Array of urls with language codes as keys and links as values.
} );
```
--------------------------------
### Define Polylang Option in pll-config.php
Source: https://polylang.pro/documentation/support/developers/php-constants
Alternatively, create a 'pll-config.php' file in '/wp-content/polylang/' to set Polylang options. This method avoids modifying wp-config.php directly.
```php
```
--------------------------------
### Get Term Translations
Source: https://polylang.pro/documentation/support/developers/function-reference
Retrieve an associative array of translations for a given term. The array keys are language codes and values are the corresponding translation term IDs.
```php
pll_get_term_translations( $term_id );
```
--------------------------------
### Get Post Translations
Source: https://polylang.pro/documentation/support/developers/function-reference
Retrieve an associative array of translations for a given post. The array keys are language codes and values are the corresponding translation post IDs.
```php
pll_get_post_translations( $post_id );
```
--------------------------------
### Display Language Switcher Without Widget
Source: https://polylang.pro/documentation/support/faq
Use this template tag in your theme files to display a language switcher. Ensure you have published content in each language to avoid 404 errors.
```php
```
--------------------------------
### Get Languages using icl_get_languages
Source: https://polylang.pro/documentation/support/developers/wpml-api
Used for building custom language selectors. Accepts an optional array of arguments to control ordering and skipping missing translations.
```php
icl_get_languages($args);
```
--------------------------------
### Update Polylang Pro Settings
Source: https://polylang.pro/documentation/support/developers/settings-rest-api
Use this endpoint to update Polylang Pro settings. Ensure you have the 'manage_options' capability. Default values are applied for unspecified parameters.
```json
{
"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"
}
}
}
```
--------------------------------
### Replace 'en' with 'en-GB' hreflang Attribute
Source: https://polylang.pro/documentation/support/developers/filter-reference
Modify hreflang attributes by replacing a specific language code with another. This example replaces 'en' with 'en-GB' on all pages.
```php
// Replaces 'en' by 'en-GB' on all pages:
add_filter( 'pll_rel_hreflang_attributes', function( $hreflangs ) {
$hreflangs['en-GB'] = $hreflangs['en'];
unset( $hreflangs['en'] );
return $hreflangs;
} );
```
--------------------------------
### Polylang CLI - Language Management
Source: https://polylang.pro/documentation/support/developers/polylang-cli
Commands for managing languages within Polylang Pro via the WP-CLI.
```APIDOC
## wp pll language
### Description
Manage your site’s languages from the command line.
### create
Add a new language to your Polylang Pro setup. Use a WordPress locale and optionally override name, slug, flag, and direction.
#### Synopsis
```
wp pll language create [--name=] [--slug=] [--flag=] [--dir=] [--order=] [--skip-default-cat]
```
#### Arguments
* **``** (string) - WordPress locale or custom locale (e.g., `en_US`, `fr_FR`). If the locale is not in the core languages list, you must provide `--name`, `--slug`, `--flag`, and `--dir`.
#### Options
* **`--name=`** (string) - Display name. If omitted, taken from Polylang’s core languages list.
* **`--slug=`** (string) - Language slug (ideally ISO 639-1, 2 letters). Must be unique. Defaults to from core list.
* **`--flag=`** (string) - Country code for the flag. Defaults to from core list.
* **`--dir=`** (string) - Text direction: `ltr` or `rtl`. Defaults to `ltr`.
* **`--order=`** (integer) - Display order. Defaults to `0`.
* **`--skip-default-cat`** - Do not create the default category for this language.
#### Examples
```bash
# Create from locale only (uses core languages list)
wp pll language create en_US
# Custom name and slug
wp pll language create en_US --name="English" --slug=en
# French with flag and order
wp pll language create fr_FR --name="Français" --slug=fr --flag=fr --order=1
# RTL language (e.g. Arabic)
wp pll language create ar --dir=rtl --order=2
# Without default category
wp pll language create es_ES --name="Español" --slug=es --skip-default-cat
```
### list
See all configured languages at a glance. Filter by slug or choose which fields to output (table, JSON, YAML, CSV).
#### Synopsis
```
wp pll language list [--=] [--fields=] [--field=] [--format=]
```
#### Options
* **`--=`** (string) - Filter by one or more fields (e.g., `--slug=en,fr`).
* **`--fields=`** (string) - Comma-separated list of fields to show. Defaults to all default fields.
* **`--field=`** (string) - Show a single field per language.
* **`--format=`** (string) - Output format: `table`, `json`, `yaml`, `csv`. Defaults to `table`.
**Default fields:** `name`, `slug`, `locale`, `term_id`, `order`, `direction`, `active`, `default`
**Optional fields:** `w3c`, `facebook`, `host`, `page_on_front`, `page_for_posts`, `flag_code`, `fallbacks`
#### Examples
```bash
# List all languages
wp pll language list
# Filter by slugs
wp pll language list --slug=en,fr,es
# Display only specific columns
wp pll language list --fields=name,slug,locale
```
### get
Retrieve a single language by its ID or slug for scripts or quick lookups.
#### Synopsis
```
wp pll language get [--fields=] [--field=] [--format=]
```
#### Arguments
* **``** (string) - Language term ID or slug.
#### Options
Same as `list` for `--fields`, `--field`, and `--format`.
#### Examples
```bash
wp pll language get en
wp pll language get 1
```
```
--------------------------------
### Add Language-Specific Capability
Source: https://polylang.pro/documentation/support/guides/how-to-manage-language-capabilities-in-polylang-pro
Use this capability to restrict users to editing or translating content in a specific language. For example, 'language_it' grants access only to Italian content.
```php
language_it
```
```php
translate_it
```
```php
translate_fr
```
--------------------------------
### Display Language Names List
Source: https://polylang.pro/documentation/support/developers/function-reference
Outputs an unordered list of language names. Ensure the `
` tags are included if not using the dropdown option.
```php
```
--------------------------------
### Add Language
Source: https://polylang.pro/documentation/support/developers/languages-rest-api
Creates a new language in Polylang. Default values are used if optional parameters are not provided.
```APIDOC
## Add Language
### Description
Creates a new language.
### Method
POST
### Endpoint
/wp-json/pll/v1/languages
### Parameters
#### Request Body
- **locale** (string) - Required - WordPress locale for the language (e.g., `en_US`). Must match pattern: `^[a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z0-9]+)?$`.
- **name** (string) - Optional - Display name for the language (e.g., “English”).
- **slug** (string) - Optional - Language code, preferably 2-letters ISO 639-1 (e.g., “en”). Must match pattern: `^[a-z][a-z0-9_-]*$`.
- **is_rtl** (boolean) - Optional - Text direction. Set to `true` for right-to-left languages.
- **flag_code** (string) - Optional - Flag code corresponding to ISO 3166-1 (e.g., “us” for United States flag).
- **term_group** (integer) - Optional - Position of the language in the language switcher. Defaults to `0`.
- **no_default_cat** (boolean) - Optional - Whether to skip creating the default category for this language. Defaults to `false`.
### Response
#### Success Response (200)
- **Language Object**: The newly created language object with properties like `term_id`, `w3c`, `facebook`, `flag_url`, `is_default`, `active`, `home_url`, `search_url`, `host`, `fallbacks`, and `term_props`.
### Example Request
```json
{
"locale": "fr_FR",
"name": "Français",
"slug": "fr",
"flag_code": "fr"
}
```
### Notes
If not provided, the default values for `name`, `slug`, `is_rtl`, and `flag_code` come from Polylang’s internal database.
```
--------------------------------
### Translate a Registered String in a Specific Language
Source: https://polylang.pro/documentation/support/developers/function-reference
Use `pll_translate_string` to get the translation of a registered string in a language other than the current one. This function requires the string and the target language code.
```php
pll_translate_string( $string, $lang );
```