<?php
add_action( 'wp_head', function() {
?>
<script>
(function($) {
const isExternalURL = (url) => new URL(url).origin !== location.origin;
document.addEventListener('facetwp-loaded', function() {
$('.facetwp-template a').each(function() {
var $this = $(this);
if (isExternalURL($this.attr('href'))) {
$this.attr('rel', 'nofollow');
}
});
});
})(jQuery);
</script>
<?php
}, 100 );