2021-01-10 11:46:16

Related Docs

Do You Need Help or Expertise?

Is editing Source Code not Your Thing? Are you in a tight Time Schedule and need to deliver a fully scalable and safe solution fast to your Clients?

Maybe you want to incorporate the Software found on TukuToi unbranded and royalty free in your Clients Projects after customizing it as per your Projects requirements?

Or eventually you need some training on any WordPress Plugin, Theme or their creation and maintenance?

FilterWPML LS on specific Post Types only

Display WPML Language Switcher 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' );