WPML
apply_filters( 'wpml_get_element_translations', mixed $empty_value, integer $trid, string $element_type)
タイプ
filter
WPMLバージョン
3.3.5

説明

  • trid(翻訳グループのID)を使用して、要素の翻訳情報を取得します。
  • tridwpml_element_tridフィルターで取得できます。
  • 詳細については、WPMLのテーブルのドキュメントページをご覧ください。

引数

$empty_value
(mixed) (必須) 通常、これはフィルターが変更する値です。ここでは何もフィルタリングしないため、NULLに設定します。これは、フィルター関数が完全な引数リストを実際に受け取るようにするためです。
$trid
(integer) (必須) 翻訳グループのIDです。
$element_type
(string) (オプション) 要素のタイプです。投稿タイプ(post_postpost_pagepost_attachmentpost_nav_menu_itempost_{custom post key})またはタクソノミー(tax_categorytax_post_tagtax_nav_menutax_{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

すべてのサイト全体の言語情報フック(29件) →