Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Created July 11, 2019 17:19
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 mgibbs189/1d4a1146f73109b68b61704cc3560435 to your computer and use it in GitHub Desktop.
Save mgibbs189/1d4a1146f73109b68b61704cc3560435 to your computer and use it in GitHub Desktop.
Pass the currently queried ID into ajax requests
<?php
// See https://facetwp.com/how-to-use-hooks/
add_action( 'wp_head', function() {
?>
<script>
(function($) {
$(document).on('facetwp-refresh', function() {
FWP_HTTP.term_id = '<?php echo get_queried_object_id(); ?>';
});
})(jQuery);
</script>
<?php
}, 100 );
// To access it (within your Query Arguments box)
$term_id = (int) $this->http_params['term_id'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment