Skip to content

Add WPML Translations to WordPress REST API Response

While integrating the WordPress REST API into a multilingual web application that my team is working on, we realized we needed a way to find out if there were translations of a specific page available, and if so, some basic details about it. The WordPress installation is running the WPML plugin to manage translations.  Google wasn’t quickly giving us any solutions to this, so I decided just to add the functionality myself.  Open Source for the win!

When querying the REST API, each post (or page, or custom post type) also returns the locale associated with that object, along with the Post ID, Permalink (URL), Post Title, and locale code for each available translation.

Today I’ve pulled that code out of our project, and released it as an isolated plugin.

Interested? For now, you can download the WPML REST API plugin from GitHub.  It’s been submitted to the WordPress plugin repository, and is awaiting approval from the wonderful volunteers there.

As always, bug reports and pull requests are welcome.

2 Comments

  1. max max

    hi Shawn,
    i’ve downloaded WPML REST API from github and loaded it up in plugins, but it does not activate. no errors, just stays inactive.
    WP version is 4.7.5
    i read it’s been tested up to 4.7.2, have you tested it on 4.7.5? any hint on what the problem may be?
    thanks for any help,
    max

  2. max max

    … just to add some more info, the server runs PHP Version 5.3.3

    thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.