Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Created March 27, 2017 13:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgibbs189/f8da7465980b1f13c58e08a7a97a99d6 to your computer and use it in GitHub Desktop.
Save mgibbs189/f8da7465980b1f13c58e08a7a97a99d6 to your computer and use it in GitHub Desktop.
Pass the current post ID to FacetWP
<?php
// See https://facetwp.com/how-to-use-hooks/
add_action( 'wp_head', function() {
?>
<script>
(function($) {
$(document).on('facetwp-refresh', function() {
FWP_HTTP.post_id = '<?php echo $post->ID; ?>';
});
})(jQuery);
</script>
<?php
}, 100 );
// To access it (within your Query Arguments box)
$post_id = (int) $this->http_params['post_id'];
@shaunw
Copy link

shaunw commented Jun 27, 2021

had to use get_queried_object_id()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment