WPML
apply_filters( 'wpml_element_has_translations', mixed $empty_value, int $element_id, string $element_type )
Loại
filter
Phiên bản WPML
3.2

Miêu tả

Trả về TRUE hoặc FALSE dựa trên việc một loại bài viết hoặc thuật ngữ phân loại có được dịch hay không.

Đố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 lọc thực sự nhận được toàn bộ danh sách đối số
$element_id
(int) (Bắt buộc) ID phần tử cần lấy thông tin. Sử dụng term_id cho các thuật ngữ phân loại, post_id cho các loại bài viết
$element_type
(string) (Bắt buộc) Loại phần tử mà ID thuộc về. Có thể là một loại bài viết: post, page, attachment, nav_menu_item, {custom post key} hoặc phân loại: category, post_tag, nav_menu {custom taxonomy key}

Ví dụ sử dụng

Ví dụ
//$is_translated will be TRUE if the custom post is translated and FALSE if it is not translated
$is_translated = apply_filters( 'wpml_element_has_translations', NULL, 61, 'book' )

wpml_element_translation_type, wpml_is_translated_post_type, wpml_is_translated_taxonomy, wpml_master_post_from_duplicate, wpml_post_duplicates

Tất cả 6 hook Tìm trạng thái dịch thuật của nội dung →