<?php
// Populates a Search facet by clicking a link with a specific class.
// Add one or more links to your page with the link text as keyword:
// <a href="#" class="searchlink">keywords here</a>
// Can be used to present search suggestions: "Try this ..."
// Replace 'my_search_facet_name' with the name of your Search facet
add_action( 'facetwp_scripts', function() {
?>
<script>
(function($) {
$('.searchlink').click(function(e) {
e.preventDefault();
var searchtext = $(this).text();
FWP.facets['my_search_facet_name'] = searchtext;
FWP.fetchData();
FWP.setHash();
});
})(jQuery);
</script>
<?php
}, 100 );