Last active
March 29, 2021 13:56
-
-
Save MWDelaney/36b94b9774fef330d98c7ee616e61fa6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
// Add facets | |
add_filter('facetwp_facets', function () { | |
// Video category checkboxes | |
$facets[] = array( | |
'label' => 'Video Category', | |
'name' => 'video_category', | |
'type' => 'radio', | |
"source" => "tax/category", | |
"parent_term" => "", | |
"orderby" => "term_order", | |
"operator" => "and", | |
"hierarchical" => "no", | |
"ghosts" => "yes", | |
"preserve_ghosts" => "yes", | |
"count" => "10", | |
"soft_limit" => "5" | |
); | |
// Return the $facets array | |
return $facets; | |
}); | |
// Insert facets before the appropriate loops | |
add_action('loop_start', function ($query) { | |
if ($query->is_post_type_archive('video')) { | |
echo '<div class="facet-container">'; | |
echo facetwp_display('facet', 'video_category'); | |
echo '</div>'; | |
} | |
}, 10); | |
// Insert facetWP template markup before the appropriate loops | |
add_action('loop_start', function ($query) { | |
if ($query->is_post_type_archive('video')) { | |
echo '<div class="facetwp-template">'; | |
} | |
}, 20); | |
// Close template loop | |
add_action('loop_end', function ($query) { | |
if ($query->is_post_type_archive('video')) { | |
echo '</div> <!-- /.facetwp-template -->'; | |
} | |
}, 20); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment