This file contains 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 'facetwp' => true to *ALL* facetwp template query args **/ | |
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) { | |
if ( true !== $query->get( 'facetwp', false ) ) { | |
return false; | |
} | |
return $is_main_query; | |
}, 10, 2 ); |
This file contains 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
/** for using flatsome equal heights setting | |
** see https://facetwp.com/how-to-use-hooks/#hooks-link for how to add this js | |
** in a snippets plugin or functions.php | |
**/ | |
(function($) { | |
$(document).on('facetwp-loaded', function() { | |
Flatsome.attach("equalize-box", $(".facetwp-template")); | |
}); | |
})(jQuery); |
This file contains 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 | |
/** fix for second lang being deleted on post index */ | |
add_filter( 'facetwp_indexer_query_args', function( $args ) { | |
if ( function_exists( 'is_checkout' ) && is_checkout() ) { | |
return $args; | |
} | |
do_action( 'wpml_switch_language', 'all' ); |
This file contains 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 | |
/** fix for woocommerce pagination not updated during facet refresh **/ | |
add_action( 'pre_get_posts', function( $query ) { | |
if ( true === $query->get( 'facetwp' ) && 'product_query' == $query->get( 'wc_query' ) ) { | |
$prefix = FWP()->helper->get_setting( 'prefix' ); | |
$name = $prefix . 'paged'; | |
// Set the paged var | |
if ( isset( FWP()->facet->http_params['get'][ $name ] ) ) { | |
set_query_var( 'paged', (int) FWP()->facet->http_params['get'][ $name ] ); |
This file contains 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_filter( 'pre_get_posts', function( $query ) { | |
if ( $query->is_main_query() && is_home() ) { | |
$query->set( 'ignore_sticky_posts', true ); | |
} | |
}); |
This file contains 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 | |
/** 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; |
This file contains 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
/** 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; | |
} |
This file contains 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 | |
/** 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']; |
This file contains 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
/** 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; | |
} |
This file contains 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 | |
/** 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 |