Skip to content

Instantly share code, notes, and snippets.

@djrmom
Created January 26, 2021 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djrmom/dd043f914fdad77d5c37acb7991826f9 to your computer and use it in GitHub Desktop.
Save djrmom/dd043f914fdad77d5c37acb7991826f9 to your computer and use it in GitHub Desktop.
facetwp redirect on refresh
<?php
/** adds script to header
**/
add_action( 'wp_head', function() { ?>
<script>
(function($) {
$(document).on('facetwp-refresh', function() {
if (FWP.loaded && 'recipes' != FWP_HTTP.uri) { // if not the initial pageload, and we're on the homepage
window.location.href = '/recipes/?' + FWP.build_query_string(); // redirect
}
});
})(jQuery);
</script>
<?php } );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment