4 min read

WPML icl_translations Table Explained: TRID and Safe Checks

The WPML icl_translations table records the language and translation group of translatable WordPress objects. If a WooCommerce product appears in the wrong language, a translated category is not connected, or a language switcher points to an unexpected item, this table can show what WPML currently knows.

Use it as a diagnostic source, not as an editing interface. A read-only query can confirm an ID, language or translation group. Direct UPDATE, INSERT or DELETE statements can bypass WPML’s public hooks and related bookkeeping.

What the icl_translations table stores

WPML creates one row for each registered translatable element. Related language versions share the same element type and trid. The numeric value of the trid is not a post ID; it identifies the translation group.

Column Meaning
translation_id The table row’s own serial ID.
element_type The WPML object type, such as post_product, post_product_variation or tax_product_cat.
element_id The WordPress post ID for post types. For taxonomy terms, it is the term_taxonomy_id, not the term_id.
trid The translation-group ID shared by related language versions of the same element type.
language_code The language assigned to this element, for example en, de or pl.
source_language_code NULL for the original element; for a translation, the language code of the original element.

The current column definitions and a simple translation-group example are documented in WPML’s database tables reference.

Before running a diagnostic query

Back up the database and work on staging when possible. The examples below use the default WordPress prefix wp_. If your site uses another prefix, replace wp_icl_translations with the real table name from that installation.

You also need the correct kind of ID. A WooCommerce product uses its post ID. A product category uses its term-taxonomy ID. Looking up a category’s term_id as though it were the stored element_id can produce an empty or misleading result.

Find the WPML row for a WooCommerce product

Replace 123 with the product’s WordPress post ID. This query does not change data:

SELECT translation_id,
       element_type,
       element_id,
       trid,
       language_code,
       source_language_code
FROM wp_icl_translations
WHERE element_type = 'post_product'
  AND element_id = 123;

A result tells you which language and translation group WPML assigned to that product. No result does not automatically prove that the product is missing. First confirm the post ID, table prefix and element_type.

Inspect every product in one translation group

After the first query returns a trid, inspect the whole group. Replace 456 with that value:

SELECT translation_id,
       element_type,
       element_id,
       trid,
       language_code,
       source_language_code
FROM wp_icl_translations
WHERE element_type = 'post_product'
  AND trid = 456
ORDER BY language_code;

This answers a narrow but useful question: which product IDs are currently linked inside that WPML translation group? If an expected language is absent, its product may not exist, may not be registered with WPML, or may exist in another group. The query alone cannot tell you which repair is appropriate.

Check a WooCommerce product category

Product categories use tax_product_cat. Their stored element_id is the WordPress term_taxonomy_id:

SELECT translation_id,
       element_type,
       element_id,
       trid,
       language_code,
       source_language_code
FROM wp_icl_translations
WHERE element_type = 'tax_product_cat'
  AND element_id = 789;

Do not substitute a category’s term_id unless it happens to equal the term-taxonomy ID. They are different identifiers even when their numeric values sometimes look similar.

How to interpret WPML translation results

  • No row: verify the database prefix, element ID and element type before treating it as a WPML relationship problem.
  • One language in the group: WPML currently has only one linked row for that trid and element type. A translation may be absent or stored in another group.
  • Unexpected language: confirm the object in WordPress and WPML’s editor before changing anything. The table shows current registration, not the history of how it happened.
  • Category lookup returns nothing: check whether you used term_taxonomy_id rather than term_id.
  • Several rows share a trid: that is the expected shape of a translation group when each row has the appropriate language.

Use WPML hooks for application code

SQL is useful when a developer needs a raw, read-only view. Application code should normally retrieve translation information through WPML’s public API. The WPML wpml_get_element_translations filter returns the elements linked to a known trid. WPML also documents wpml_element_language_details for reading one element’s language information.

$element_type = apply_filters( 'wpml_element_type', 'product' );
$trid = apply_filters( 'wpml_element_trid', null, $product_id, $element_type );

$translations = $trid
    ? apply_filters( 'wpml_get_element_translations', null, $trid, $element_type )
    : [];

To set or connect language details, use WPML’s documented wpml_set_element_language_details action or a tool that uses WPML-aware code paths. Do not translate the diagnostic SELECT statements above into hand-written update queries.

A safer troubleshooting sequence

  1. Back up the database and reproduce the problem on staging.
  2. Identify the exact post ID or term-taxonomy ID and the expected WPML element type.
  3. Run a narrow read-only query for that element.
  4. Inspect the complete trid group.
  5. Compare the result with the product, category and language relationships visible in WordPress and WPML.
  6. Repair the relationship through WPML’s interface, public hooks or an importer that follows the WPML lifecycle.
  7. Run the same SELECT again and verify the frontend language switcher.

If you are diagnosing an import rather than WPML’s table itself, continue with the common WPML WooCommerce import problems or see the complete Shirely WPML import workflow.