Some applications use XML-RPC to edit WordPress sites. Most notably are the WordPress iPhone and BlackBerry applications.

Language custom fields

WPML allows controlling post and page languages via custom fields.

  • _wpml_language (R/W): The short ISO language code. For example, ‘en’, ‘es’, ‘fr’, ‘de’.
  • _wpml_trid (R/W): The translation group ID. Items with the same trid are considered as translations for one another.
  • _wpml_translations (R): A serialized array containing the translations for a post or page.

WPML adds the language custom fields to these XML-RPC calls:


  • metaWeblog.newPost or wp.newPage
  • metaWeblog.editPost or wp.editPage


  • wp.getPage
  • metaWeblog.getPost
  • metaWeblog.getRecentPosts

When a page/post is read, WPML sets the trid and language attributes. The actual values for these are stored in WPML’s translations table and the values are copied to the custom field when the RPC is called.

Please note: The “Reading” part of this feature is currently missing. We are working on it and will update you when it is ready.

When writing, WPML monitors for the presence of these custom fields and will update the translations table according to them.


1. Get language information


This will return a list of all available languages for the site. This list should be used to display languages and translation options for posts, pages, tags and categories.

Accepts one (optional) parameter: language code. Besides the English and native names, languages will be returned in this language as well.

1. Create a new page (or post)


In the application, include a drop-down window that allows selecting the language of the page.

Add the _wpml_language custom field to tell WPML the language of this new page.

2. Read a page from WordPress and display it (with translation controls)


This will return _wpml_language, _wpml_trid and _wpml_translations.

_wpml_translations needs to be unserialized. It will contain an array of language codes and the IDs of translations for this page. Any existing translation will be greater than zero. Languages with no translations will get an ID of zero.

The application can now display the language of the page and all existing translations and allow adding new translations or editing existing translations.

The trid value is kept, but doesn’t need to be displayed anywhere.

3. Add translation to a page


Include both _wpml_language and _wpml_trid. The trid value is the same as for the page we’re adding translation to. The language must be unique to the trid.


Two posts or pages cannot have the same trid and language values. All elements in the same trid must have unique languages.

If you edit an existing page or try to create a new page which causes the translation group to have two elements with the same number, the RPC will fail, returning an error.

For more information on WPML’s internals, have a look at the table structure.

2 Responses to “XML-RPC language interface”

  1. Mike says:

    The XML-RPC implementation appears to be affected by this issue:

    The latest version of WPML does not seem to use the available register_meta() method to allow the modification of the protected _[meta_key] custom fields.

    The following quick hack will enable sending the custom field _wpml_language and _wpml_trid via XML-RPC. This does _NOT_ properly enforce permissions or perform any kind of sanitization.

    @@ -3,7 +3,8 @@
    class WPML_Translation_Management{

    function __construct(){
    – add_action(‘init’, array($this,’init’));
    + add_action(‘init’, array($this,’init’));
    + add_action(‘init’, array($this,’_register_meta’));

    function __destruct(){
    @@ -57,6 +58,19 @@


    + }
    + function _meta_sanitize_cb ( $meta_value, $meta_key, $meta_type ) {
    + return $meta_value;
    + }
    + function _meta_yes_you_can( $can, $key, $post_id, $user_id, $cap, $caps ) {
    + return true;
    + }
    + function _register_meta(){
    + register_meta( ‘post’, ‘_wpml_language’, array($this,’_meta_sanitize_cb’), array($this,’_meta_yes_you_can’));
    + register_meta( ‘post’, ‘_wpml_trid’, array($this,’_meta_sanitize_cb’), array($this,’_meta_yes_you_can’));

    function _no_wpml_warning(){

  2. Hi.
    When was this added to wpm? I*m doing some testing with the wordpress for android app, but those values are not returned on a wp.getPost request.

    I’m only running the wpml from

Leave a Reply

Please leave here comments about this page only.
For technical support and feature suggestions, head to our forum. We are waiting there!

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>