Gists

by mgibbs189 - 6 hours ago

(function($) {
    
    $(document).on('facetwp-loaded', function() {
        var in_use = false;

        // see if any facets are in use
        $.each(FWP.facets, function(name, val) {
            if (val.length > 0) {
                in_use = true;
            }
        }

        // true = show, false = hide
        $('.facetwp-reset-btn').toggle(in_use);
    });
    
})(jQuery);
by djrmom - 1 day ago

<?php

/** use do_shortcode on all layout builder items
 ** it is preferrable to target specific items
 ** as in https://facetwp.com/documentation/developers/output/facetwp_builder_item_value/
 ** if possible
 **/
add_filter( 'facetwp_builder_item_value', function( $value, $item ) {
    $value = do_shortcode( $value ); 
    return $value;
}, 10, 2 );
by djrmom - 6 days ago

/** hide enable filtering button **/
.facetwp-map-filtering {
	display: none;
}

/** hides map markers **/
.gm-style > div:first-of-type > div:first-of-type > div > div:nth-of-type(2) {
    display:  none;
}
by djrmom - 1 week ago

<?php

/** custom index to display a dropdown facet as a range
 ** change 'CHANGE_ME' to the name of your facet
 ** facet settings should be a dropdown type and the datasourc
 ** of the value you want to show as a range **/

add_filter( 'facetwp_index_row', function( $params, $class ) {
    if ( 'CHANGE_ME' == $params['facet_name'] ) {  
        $price = $params['facet_value'];
        switch ( true ) {
            case ( $price < 10 ):
                $params['facet_value'] = '10';
                $params['facet_display_value'] = 'Less than $10';
                break;
            case ( $price <= 50 ):
                $params['facet_value'] = '50';
                $params['facet_display_value'] = '$10 to $50';
                break;
            case ( $price > 50 ):
                $params['facet_value'] = '100';
                $params['facet_display_value'] = 'over $50';
                break;   
            default: // no value
                return false;
        }
	} 
    return $params;
}, 10, 2 );
by mgibbs189 - 1 week ago

<?php

// Add to your (child) theme's functions.php, or into the Custom Hooks plugin!

add_action( 'wp_head', function() {
?>
<script>
(function($) {

    FWP.hooks.addFilter('facetwp/flyout/facets', function(facets) {
        return ['facet3', 'facet1', 'facet2']; // change the facet display order
    });

})(jQuery);
</script>
<?php
}, 100 );

by djrmom - 1 week ago

/** hides map markers on facetwp map facet with css **/

.gm-style > div:first-of-type > div:first-of-type > div > div:nth-of-type(2) {
    display:  none;
}

by djrmom - 1 week ago

<?php
/** create a range list facet with the ranges you need
 ** create a dropdown facet with any datasource, post type is good its just a placeholder
 ** change the code below to match your facet names
 **/

add_filter( 'facetwp_index_row', function( $params, $class ) {
	if ( 'my_range_facet' == $params['facet_name'] ) { // change 'my_range_facet' to the name of your range list facet
		$params['facet_name'] = 'dropdown_range'; // trick FacetWP into saving values into the other facet
	} elseif ( 'dropdown_range' == $params['facet_name'] ) { // change 'dropdown_range' to the name of your dropdown facet in this and the above line 
		return false;
	}
    return $params;
}, 10, 2 );
by mgibbs189 - 2 weeks ago

<?php

// Add to your (child) theme's functions.php and re-index afterwards!

add_filter( 'facetwp_index_row', function( $params, $class ) {
	if ( 'recognition' == $params['facet_name'] ) {
		$new_params = $params;
		$label = $params['facet_display_value'];

		if ( false !== strpos( $label, 'National Winner' ) ) {
			$new_params['facet_value'] = 'national-winners';
			$new_params['facet_display_value'] = 'All National Winners';
			$class->insert( $new_params );

			$new_params['facet_value'] = 'all-winners';
			$new_params['facet_display_value'] = 'All Winners';
			$class->insert( $new_params );
		}

		if ( false !== strpos( $label, 'Place in School' ) ) {
			$new_params['facet_value'] = 'all-winners';
			$new_params['facet_display_value'] = 'All Winners';
			$class->insert( $new_params );
		}
	}

	return $params;
}, 10, 2 );

by djrmom - 3 weeks ago

$(function() {       
	FWP.hooks.addFilter('facetwp/template_html', function() {
		return true;
	}, 200 );
});
by djrmom - 3 weeks ago

/** adjust as needed to fit mobile phones better **/

@media only screen and (max-width: 767px) {
    #facetwp-radius {
        display:block;
        float: none;
        width: 100%;
    }
    .location-wrap {
        width: 100%
    }
    .locate-me:before {
        width: 50px;
        height: 50px;
        background-position: center;
    }
}