Polylang REST API Connector
Expose Polylang language and translation data to the WordPress REST API to allow an external automation tool (i.e. n8n) to read translation status and link new translations programmatically.
by japaneseknotweed · github.com/japaneseknotweedbe/polylang-rest-connector
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/japaneseknotweedbe/polylang-rest-connector/archive/refs/heads/main.zipExpose Polylang language and translation data to the WordPress REST API to allow an external automation tool (i.e. n8n) to read translation status and link new translations programmatically.
Instructions
-
Create a file named polylang-rest-connector.php.
-
Paste the code below into that file.
-
Upload it to your wp-content/plugins/ folder and activate it, OR place it inside wp-content/mu-plugins/ to force activation.
Implementation Details
-
Security: Checks if Polylang is active (function_exists('pll_default_language')) before executing to prevent site crashes.
-
Dynamic Support: Automatically detects all public post types (Posts, Pages, etc.) via get_post_types.
-
Read (GET): Adds lang (string) and translations (object) to the API response.
-
Write (POST/PUT): Hooks into rest_insert_{post_type} to handle the side-effects of setting language and linking translations.