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