Delete the lang / language variable in the AJAX refresh for Polylang or WPML with the Multilingual add-on

<?php

// Removes the language variable for templates that need to query and filter posts with no language set
// See: https://facetwp.com/help-center/using-facetwp-with/multilingual/#fix-issues-with-filtering-posts-with-no-language-set

add_action( 'facetwp_scripts', function() {
 
  // Use the correct conditional for your template(s), e.g. is_archive(), is_page(), is_category() etc.
  // See: https://codex.wordpress.org/Conditional_Tags
  if ( is_post_type_archive( 'my_custom_post_type' ) ) { 
    ?>
    <script>
      document.addEventListener('facetwp-refresh', function() {
        delete FWP_HTTP['lang'];
      });
    </script>
    <?php
  }
}, 100 );