apply_filters( 'wpml_get_element_translations', mixed $empty_value, integer $trid, string $element_type)
- Loại
- filter
- Danh mục
- Thông tin ngôn ngữ toàn trang web
- Phiên bản WPML
- 3.3.5
Miêu tả
- Lấy thông tin các bản dịch của phần tử bằng cách sử dụng
trid(ID của nhóm bản dịch). tridcó thể được lấy bằng bộ lọc wpml_element_trid.- Tìm hiểu thêm về điều này trên trang tài liệu các bảng của WPML.
Đối số
- $empty_value
- (mixed) (Bắt buộc) Đây thường là giá trị mà bộ lọc sẽ sửa đổi. Chúng ta không lọc bất kỳ thứ gì ở đây, vì vậy hãy đặt giá trị này thành NULL. Điều này giúp hàm bộ lọc thực sự nhận được danh sách đối số đầy đủ.
- $trid
- (integer) (Bắt buộc) ID của nhóm bản dịch.
- $element_type
- (string) (Tùy chọn) Loại của một phần tử. Có thể là một loại bài viết: post_post, post_page, post_attachment, post_nav_menu_item, post_{custom post key} hoặc phân loại: tax_category, tax_post_tag, tax_nav_menu, tax_{custom taxonomy key}. Mặc định là
post_postnếu không được thiết lập.
Ví dụ sử dụng
Ví dụ
$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"
}
}
*/
Các hook liên quan
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