Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@khromov
Created February 14, 2017 21:28
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 khromov/776d02cf1794c4328eca5076a946b075 to your computer and use it in GitHub Desktop.
Save khromov/776d02cf1794c4328eca5076a946b075 to your computer and use it in GitHub Desktop.
Load WPFacet facets from facets.json file in theme
<?php
//...
add_filter( 'facetwp_facets', function($facets) {
//Load facets.json file located in theme folder
$imported_facets = json_decode(file_get_contents(trailingslashit(dirname(__FILE__)) . 'facets.json'), true);
//Import facets
foreach($imported_facets['facets'] as $single_facet) {
$facets[] = $single_facet;
}
return $facets;
});
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment