Polylang REST
A Wordpress Plugin to Exposes a post's Polylang language and translation map over the WP REST API
by Reinhard Mengelberg · github.com/reinmengelberg/polylang-rest
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/reinmengelberg/polylang-rest/archive/refs/heads/main.zipExposes a post's Polylang language and translation map over the WP REST API, and makes /wp/v2/posts?lang=<code> filter by it.
Free Polylang doesn't do this on its own (it's a Polylang Pro feature).
- Author: Reinhard Mengelberg
- Version: 1.0.0
Install
Pick one of these two paths.
A) As a must-use plugin
No WP admin UI, can't be disabled by accident.
- Copy this file to your WP install at:
wp-content/mu-plugins/polylang-rest.phpCreate the
mu-pluginsdirectory if it doesn't exist. - Done.
mu-pluginsauto-load — no activation step, and they don't appear under WP admin → Plugins, so they can't be deactivated from the GUI. Requires SFTP / host file-manager access.B) As a regular plugin
Installs via WP admin GUI, deactivatable.
- On your computer, put this file inside a folder of the same name:
polylang-rest/polylang-rest.php - Zip the folder →
polylang-rest.zip - WP admin → Plugins → Add New → Upload Plugin → pick the zip → Install Now → Activate. Trade-off vs (A): anyone with plugin admin can deactivate this from the GUI, which silently breaks the Nuxt sync's language detection.
Verify
After either path, confirm it's working by hitting:
https://applyfin.com/blog/wp-json/wp/v2/posts?per_page=1
The response post should now include a lang field (e.g. "nl") and a translations object (e.g. {"en": 101}). Empty values are normal for posts not yet assigned a Polylang language.
Notes
- No-ops gracefully when Polylang is inactive (returns
nullforlangand an empty array fortranslations), so this file is safe to leave in place even if Polylang is temporarily disabled. - We only register on the
posttype because that's all the Nuxt sync pulls. If you later sync pages or a custom post type, add it here.