WP Manifestindependent plugin directory
manifest / i18n / polylang-rest

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

0stars
0forks

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.zip

Exposes 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.

  1. Copy this file to your WP install at:
    wp-content/mu-plugins/polylang-rest.php

    Create the mu-plugins directory if it doesn't exist.

  2. Done. mu-plugins auto-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.

  1. On your computer, put this file inside a folder of the same name:
    polylang-rest/polylang-rest.php
  2. Zip the folder → polylang-rest.zip
  3. 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 null for lang and an empty array for translations), so this file is safe to leave in place even if Polylang is temporarily disabled.
  • We only register on the post type because that's all the Nuxt sync pulls. If you later sync pages or a custom post type, add it here.