Gists

10 months ago
<?php
/** captures pagination for use with facet
 ** pager must be within facetwp-template class
 ** change 'a.page-numbers' to match element of the links ln 12
 ** ln 14 matches on page link format of /page/x/, change if needed
 **/

add_action( 'facetwp_scripts', function() {
    ?>
    <script>
        (function($) {
            $().on('click', 'a.page-numbers', function(e) {
                e.preventDefault();
                var matches = $(this).attr('href').match(/\/page\/(\d+)/);
                if (null !== matches) {
                    FWP.paged = parseInt(matches[1]);
                    FWP.soft_refresh = true;
                    FWP.refresh();
                }
            });
        })(fUtil);
    </script>
    <?php
}, 100 );
7 years ago
<?php

// Add this code!
add_action( 'wp_footer', function() {
?>
<script>
(function($) {
    $(document).on('click', '.woo-pagination a', function(e) {
        e.preventDefault();
        var matches = $(this).attr('href').match(//page/(d+)/);
        if (null !== matches) {
            FWP.paged = parseInt(matches[1]);
            FWP.soft_refresh = true;
            FWP.refresh();
        }
    });
})(jQuery);
</script>
<?php
}, 100 );
8 years ago
<?php

function fwp_custom_pager() {
?>
<script>
(function($) {
    $(document).on('click', '.pagination a', function(e) {
        if ('object' === typeof FWP) {
            e.preventDefault();
            var matches = $(this).attr('href').match(//page/(d+)/);
            if (null != matches) {
                FWP.paged = parseInt(matches[1]);
            }
            FWP.soft_refresh = true;
            FWP.refresh();
        }
    });
})(jQuery);
</script>
<?php
}
add_action( 'wp_head', 'fwp_custom_pager', 100 );
8 years ago
function fwp_pager_handler() {
?>
<script>
(function($) {
    $(document).on('facetwp-refresh', function() {
        if (! FWP.loaded) {
            $(document).on('click', '.pagination a', function(e) {
                e.preventDefault();
                var matches = jQuery(this).attr('href').match(//page/(d+)/);
                if (null != matches) {
                    FWP.paged = parseInt(matches[1]);
                }
                FWP.soft_refresh = true;
                FWP.refresh();
            });
        }
    });
})(jQuery);
</script>
<?php
}
add_action( 'wp_footer', 'fwp_pager_handler', 100 );
2 years ago
<?php

// If your website is not in English, change "page" matches in line 14 to whatever it is in your language.

function fwp_pagenavi_support() {
?>
<script>
(function($) {
    $(document).on('facetwp-refresh', function() {
        if (! FWP.loaded) {
            $(document).on('click', '.wp-pagenavi a.page', function(e) {
                e.preventDefault();
                var matches = $(this).attr('href').match(/\/page\/(\d+)/);
                if (null != matches) {
                    FWP.paged = parseInt(matches[1]);
                }
                FWP.soft_refresh = true;
                FWP.refresh();
            });
        }
    });
})(jQuery);
</script>
<?php
}
add_action( 'wp_head', 'fwp_pagenavi_support', 50 );
8 years ago
(function($) {
    $(document).on('click', '.pagination a', function(e) {
        e.preventDefault();
        var matches = $(this).attr('href').match(//page/(d+)/);
        if (null != matches) {
            FWP.paged = parseInt(matches[1]);
        }
        FWP.soft_refresh = true;
        FWP.refresh();
    });
})(jQuery);