Skip to content Skip to sidebar
availability:

WPML Version: 4.6.7

description:

When Translate Everything Automatically is enabled, WPML translates a post automatically as soon as it is created or updated.

If you need to exclude specific posts from being translated by TEA, you can do so by using a filter that excludes posts by their IDs.

Important:
WPML triggers translation on the save_post action. Make sure to add this filter as early as possible—before the save_post action runs.

Also note that this hook only works while Translate Everything Automatically is already running; it does not apply when starting TEA for the first time.

type:
filter
category:
Miscellaneous
parameters:
add_filter( 'wpml_exclude_post_from_auto_translate', callable $function_to_add, 10, 2 );

Callback Function Parameters

The callback function accepts two parameters:

  • $exclude (bool)Set to true to exclude the post from translation, or false to allow translation.
  • $postId (int)The ID of the post being translated.
hook example usage:

Example

add_filter(
 'wpml_exclude_post_from_auto_translate',
 function ( $exclude, $postId ) : bool {
  $postIdsToExclude = [ 10, 11, 12 ]; // Post IDs to exclude from Translate Everything.

  return in_array( $postId, $postIdsToExclude, true );
 },
 10,
 2
);