Skip to content

Instantly share code, notes, and snippets.

@mihdan
Forked from mgibbs189/example.js
Created May 25, 2020 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mihdan/6e466e701e4fe7f3daa30f102e45d0dd to your computer and use it in GitHub Desktop.
Save mihdan/6e466e701e4fe7f3daa30f102e45d0dd to your computer and use it in GitHub Desktop.
FacetWP - REST API - ajax example
<script>
(function($) {
$(function() {
var data = {
'facets': {
'make': ['audi'],
'vehicle_type': []
},
'query_args': {
'post_type': 'cars',
'posts_per_page': 4,
'paged': 1
},
};
$.ajax({
type: 'POST',
url: 'http://wp.dev/wp-json/facetwp/v1/fetch',
data: { data: JSON.stringify(data) },
success: function(response) {
console.log(response);
}
});
});
})(jQuery);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment