WPML
apply_filters( 'wpml_get_element_translations', mixed $empty_value, integer $trid, string $element_type)
Type
filter
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.

On the front end, the result contains only the translations the current user can read. Visitors get published translations, also of post types that are not public. They do not get drafts, private, pending or future posts. From WPML 5.3, this includes page-builder templates and layouts.

Arguments

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

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"
  }
}
 */

wpml_decode_custom_field, wpml_footer_language_selector, wpml_add_language_form_field, wpml_ls_exclude_in_menu, wpml_is_rtl, wpml_alternate_hreflang, wpml_head_langs, wpml_must_translate_canonical_url, wpml_browser_redirect_language_params, wpml_redirect_to_chosen_language

All 31 Site-Wide Language Information hooks