apply_filters( 'wpml_get_element_translations', mixed $empty_value, integer $trid, string $element_type)
- 类型
- filter
- 类别
- 全站语言信息
- WPML 版本
- 3.3.5
说明
- 使用
trid(翻译组的 ID)获取元素翻译信息。 trid可以通过 wpml_element_trid 过滤器获取。- 在 WPML 的表文档页面上了解有关此内容的更多信息。
参数
- $empty_value
- (mixed) (必填) 这通常是过滤器将要修改的值。我们在这里不进行任何过滤,因此将其设置为 NULL。这是为了让过滤器函数能够实际接收完整的参数列表。
- $trid
- (integer) (必填) 翻译组的 ID。
- $element_type
- (string) (可选) 元素的类型。可以是文章类型:post_post、post_page、post_attachment、post_nav_menu_item、post_{custom post key},或者是分类法:tax_category、tax_post_tag、tax_nav_menu、tax_{custom taxonomy key}。如果未设置,则默认为
post_post。
使用示例
示例
$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_active_languages