WPML
apply_filters( 'wpml_elements_without_translations', array $element_ids, array $args )
Loại
filter
Phiên bản WPML
3.2.2

Miêu tả

Hook bộ lọc này có thể được sử dụng để truy xuất các phần tử không có bản dịch

Đối số

$element_ids
(array) (Bắt buộc) Một mảng các ID phần tử. Mặc định là một mảng rỗng.
$args
(array) (Bắt buộc) Một mảng các đối số sẽ được sử dụng.
  • target_language(bool) Mã ngôn ngữ đích. Mã gồm 2 chữ cái
  • source_language(bool) Mã ngôn ngữ nguồn. Mã gồm 2 chữ cái
  • element_type(string) Loại phần tử cần kiểm tra. 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

Trong ví dụ bên dưới, chúng ta muốn tìm xem những bài viết blog nào chưa được dịch sang tiếng Hy Lạp.
Lưu ý cách chúng ta truyền một mảng các ID bài viết làm đối số đầu tiên để nếu WPML không hoạt động, chúng ta sẽ nhận lại mảng đó.

Ví dụ
$get_post_args = array( 'posts_per_page' => -1, );
$posts_array = get_posts( $get_post_args );
$post_ids = array();
foreach ( $posts_array as $post ) {
	$post_ids[] += $post->ID;
}

$wpml_filter_args = array(
'element_type' => 'post',
'source_language' => 'en',
'target_language' => 'el'
);
$posts_without_greek_translations = apply_filters( 'wpml_elements_without_translations', $post_ids, $wpml_filter_args );

wpml_media_url, wpml_media_id, force_suppress_filters, wpml_get_translated_slug, wpml_home_url, wpml_translate_single_string, wpml_translate_string, wpml_permalink, wpml_unfiltered_admin_string, wpml_element_link

Tất cả 12 hook Truy xuất nội dung đã bản địa hóa →