add_filter( 'wpml_exclude_post_from_auto_translate', callable $function_to_add, 10, 2 );
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.
Arguments
Callback Function Parameters
The callback function accepts two parameters:
$excludeboolSet to true to exclude the post from translation, or false to allow translation.$postIdintThe ID of the post being translated.
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 );