Skip Navigation
availability:

WPML Version: 3.2.2

description:

This filter hook will retrieve the language code for a translatable element by querying WPML’s icl_translations database table.

Also look at wpml_element_language_details if you are interested in more information such as the element’s trid

type:
filter
category:
Retrieving Language Information for Content
parameters:
apply_filters( 'wpml_element_language_code', string $language_code, array $args )
$language_code
(string) (Required) A 2-letter language code. Defaults to null.
$args
(array) (Required) An array of arguments to be used.

  • element_id(bool) Use term_taxonomy_id for taxonomies, post_id for posts
  • 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:

Example

$args = array('element_id' => 10, 'element_type' => 'category' );
$my_category_language_code = apply_filters( 'wpml_element_language_code', null, $args );