Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. <?php
  2. /** prepend selected value label of fselect with default value **/
  3. add_action( 'wp_footer', function() {
  4. ?>
  5. <script>
  6. (function($) {
  7. if ('object' !== typeof FWP) {
  8. return;
  9. }
  10. $(function() {
  11. FWP.hooks.addAction('facetwp/loaded', function() {
  12. $('.facetwp-type-fselect').each(function() {
  13. var facet_name = $(this).attr('data-name');
  14. var facet_label = $(this).find('.facetwp-dropdown > option:first-child').text();
  15. if ( 'undefined' !== typeof FWP.facets[facet_name] && FWP.facets[facet_name].length > 0 ) {
  16. $(this).find('.fs-label').prepend( facet_label + ': ' );
  17. }
  18. });
  19. }, 100 );
  20. });
  21. })(jQuery);
  22. </script>
  23. <?php
  24. }, 100 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement