Skip Navigation
availability:

WPML Version: 3.3.5

description:
  • Get the element translations info using trid (the ID of the translation group).
  • trid can be retrieved by the wpml_element_trid filter.
  • Learn more about this on the WPML’s tables documentation page.
type:
filter
category:
Site-Wide Language Information
parameters:
apply_filters( 'wpml_get_element_translations', mixed $empty_value, integer $trid, string $element_type)
$empty_value
(mixed) (Required) This is usually the value the filter will be modifying. We are not filtering anything here so set this to NULL. This for the filter function to actually receive the full argument list.
$trid
(integer) (Required) The ID of the translation group.
$element_type
(string) (Optional) The type of an element. Can be a post type: post_post, post_page, post_attachment, post_nav_menu_item, post_{custom post key} or taxonomy: tax_category, tax_post_tag, tax_nav_menu, tax_{custom taxonomy key}. Defaults to post_post if not set.
hook example usage:

Example


$translations = apply_filters( 'wpml_get_element_translations', NULL, 2, 'post_page' );
var_dump($translations);
/**
 * The result looks like the following 
 * 
array(2) {
  ["en"]=>
  object(stdClass)#1857 (8) {
    ["translation_id"]=>
    string(1) "1"
    ["language_code"]=>
    string(2) "en"
    ["element_id"]=>
    string(1) "2"
    ["source_language_code"]=>
    NULL
    ["element_type"]=>
    string(9) "post_page"
    ["original"]=>
    string(1) "1"
    ["post_title"]=>
    string(4) "Home"
    ["post_status"]=>
    string(7) "publish"
  }
  ["es"]=>
  object(stdClass)#1856 (8) {
    ["translation_id"]=>
    string(3) "141"
    ["language_code"]=>
    string(2) "es"
    ["element_id"]=>
    string(3) "187"
    ["source_language_code"]=>
    string(2) "en"
    ["element_type"]=>
    string(9) "post_page"
    ["original"]=>
    string(1) "0"
    ["post_title"]=>
    string(6) "Inicio"
    ["post_status"]=>
    string(7) "publish"
  }
}
 */