-
-
Save stevesearer/e8509b6a4b6b19aceee0349e4c6f1160 to your computer and use it in GitHub Desktop.
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 | |
function fwp_preload_facets() { | |
?> | |
<script> | |
(function($) { | |
$(document).on('facetwp-refresh', function() { | |
if (! FWP.loaded && '' == FWP.build_query_string()) { | |
FWP_HTTP.post_id = '<?php global $post; ?><?php echo $post->ID; ?>'; | |
FWP.facets['product_availability'] = ['americas']; | |
} | |
}); | |
})(jQuery); | |
</script> | |
<?php | |
} | |
add_action( 'wp_head', 'fwp_preload_facets', 100 ); | |
add_filter( 'facetwp_template_force_load', '__return_true' ); | |
// My Template Query Arguments | |
$post_id = (int)(isset($this->http_params['post_id']) ? $this->http_params['post_id'] : null); | |
return array( | |
'post_type' => 'products', | |
'posts_per_page' => -1, | |
'post_status' => 'publish', | |
'order' => 'ASC', | |
'orderby' => 'title', | |
'meta_query' => array( | |
array( | |
'key' => 'product_parent_id', | |
'compare' => '=', | |
'type' => 'numberic', | |
'value' => $post_id, | |
) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment