Voeg deze code toe aan functions.php van je thema of in Code Snippets plugin.


function fwp_add_facet_labels() {
  ?>
    <script>
      (function($) {
        $(document).on('facetwp-loaded', function() {
          $('.facetwp-facet').each(function() {
            var facet = $(this);
            var facet_name = facet.attr('data-name');
            var facet_type = facet.attr('data-type');
            var facet_label = FWP.settings.labels[facet_name];
            if (facet_type !== 'pager' && facet_type !== 'sort') {
              if (('undefined' === typeof FWP.settings.num_choices[facet_name] ||
                ('undefined' !== typeof FWP.settings.num_choices[facet_name] && FWP.settings.num_choices[facet_name] > 0)) && $('.facet-label[data-for="' + facet_name + '"]').length < 1) {
                facet.before('<h3 class="facet-label" data-for="' + facet_name + '">' + facet_label + '</h3>');
              } else if ('undefined' !== typeof FWP.settings.num_choices[facet_name] && !FWP.settings.num_choices[facet_name] > 0) {
                $('.facet-label[data-for="' + facet_name + '"]').remove();
              }
            }
          });
        });
      })(jQuery);
    </script>
  <?php
}

add_action( 'wp_footer', 'fwp_add_facet_labels', 100 );