wpml_exclude_post_from_auto_translate
- タイプ
- filter
- カテゴリー
- その他
- WPMLバージョン
- 4.6.7
説明
「すべてを自動翻訳する」が有効になっている場合、WPMLは投稿が作成または更新されるとすぐに自動的に翻訳します。
特定の投稿をTEAによる翻訳から除外する必要がある場合、IDによって投稿を除外するフィルターを使用して実行できます。
重要:
WPMLはsave_postアクションで翻訳をトリガーします。このフィルターは、save_postアクションが実行される前の、できるだけ早い段階で追加してください。
また、このフックは「すべてを自動翻訳する」がすでに実行されている間にのみ機能することに注意してください。初めてTEAを開始する場合には適用されません。
引数
add_filter( 'wpml_exclude_post_from_auto_translate', callable $function_to_add, 10, 2 );
コールバック関数のパラメーター
コールバック関数は2つのパラメーターを受け取ります。
- $exclude (bool)投稿を翻訳から除外する場合はtrueを設定し、翻訳を許可する場合はfalseを設定します。
- $postId (int)翻訳される投稿のIDです。
使用例
例
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
);
関連するフック
icl_ls_languages, wpml_sync_custom_field_copied_value, wpml_ls_enable_ajax_navigation, wpml_element_type, wpml_setting, wpml_sub_setting, wpml_forms_config_ninja-forms, wpml_forms_config_wpforms, wpml_tf_feedback_open_link, wpml_translatable_user_meta_fields