Related Docs

Did not find what you're looking for? Search the complete TukuToi Software Documentation

Filter

WPML LS on specific Post Types only

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. The code – as usual for filters – goes to the functions.php file.
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' );