availability:

WPML Version: 3.2.2

description:

This filter hook can be used to retrieve elements without translations

type:
filter
category:
Retrieving Localized Content
parameters:
apply_filters( 'wpml_elements_without_translations', array $element_ids, array $args )
$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}
hook 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 );