apply_filters( 'wpml_elements_without_translations', array $element_ids, array $args )
- Type
- filter
- Category
- Retrieving Localized Content
- WPML Version
- 3.2.2
Description
This filter hook can be used to retrieve elements without translations
Arguments
- $element_ids
- (array) (Required) An array of element ids. Defaults to an empty array.
- $args
- (array) (Required) An array of arguments to be used.
- target_language(bool) The target language code. A 2-letter code
- source_language(bool) The source language code. A 2-letter code
- element_type(string) The type of element to check. Can be a post type: post, page, attachment, nav_menu_item, {custom post key} or taxonomy: category, post_tag, nav_menu {custom taxonomy key}
Example usage
In the example below we want to find out which blog posts have not yet been translated into Greek.
Note how as first argument we pass an array of post ids so that if WPML is not active we will get that back.
Example
$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 );Related hooks
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