This code will prevent rendering the language switcher if the current post type is not a “post” or a “product”: of course, you can customize it based on your needs.
Add this to functions.php:
<pre>
function remove_wpml_post_alternative_languages( $html ) { $allowedPostTypes = [ 'post', 'product', ]; if ( ! in_array( get_post_type(), $allowedPostTypes, true ) ) { return ''; } return $html; } add_filter( 'wpml_ls_post_alternative_languages', 'remove_wpml_post_alternative_languages' );
</pre>