Skip to content

Instantly share code, notes, and snippets.

View remcokalf's full-sized avatar

Remco Kalf remcokalf

View GitHub Profile
@remcokalf
remcokalf / facetwp 3.8+ dropdowns with chosen()
Last active July 29, 2022 15:18
Fixes for dropdowns facets and sortbox with .chosen() in FacetWP 3.8.0 - 3.8.2 because Facetwp fUtil library did not pick up jQuery.trigger change events from chosen() in these FacetWP versions. This was fixed in FacetWP 3.8.3+. Check this page for current versions of FacetWP: https://gist.facetwp.com/gist/use-chosen-js-with-facetwp-dropdowns-or…
(function ($) {
$(document).on('facetwp-loaded', function () {
// Facetwp Dropdowns to chosen dropdows
$('.facetwp-dropdown option:first-child').text('');
$('.facetwp-dropdown').attr('data-placeholder', 'All');
$('.facetwp-dropdown').chosen({disable_search_threshold: 50, allow_single_deselect: true});
// Facetwp Sort box to chosen dropdows
@remcokalf
remcokalf / gist:f3b57ca4e6b528c8337c17aa6826a819
Last active December 23, 2016 11:21
Get padded term count in term search results with SearchWP and Term Archive Priority
//Code in search loop for term item:
$tax = $post->term->taxonomy;
$termid = $post->term->term_id;
$termchildren = get_term_children( $termid, $tax);
if ( !empty( $termchildren ) && !is_wp_error( $termchildren ) ){
$termchildren[] = $termid; //add parent to the array of children