Created
January 26, 2021 19:16
-
-
Save djrmom/dd043f914fdad77d5c37acb7991826f9 to your computer and use it in GitHub Desktop.
facetwp redirect on refresh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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