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 to your (child) theme's functions.php | |
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) { | |
if ( 2 > $query->get( 'posts_per_page', 0 ) ) { | |
$is_main_query = 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
<?php | |
/** adds script to header | |
** https://facetwp.com/how-to-add-pagination-scrolling/ | |
**/ | |
add_action( 'wp_head', function() { ?> | |
<script> | |
(function($) { | |
$(document).on('facetwp-loaded', function() { | |
if (FWP.loaded) { | |
$('html, body').animate({ |
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 | |
/** if facet is identifying the wrong query in elementor | |
** add a custom query id 'block_facet' to your query settings in the element | |
** to NOT have facet identify as the main query | |
** https://developers.elementor.com/custom-query-filter/ | |
**/ | |
add_action( 'elementor/query/block_facet', function( $query ) { | |
$query->set( 'facetwp', false ); | |
} ); |
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 | |
/** close flyout on facetwp-loaded so that the user doesn't need to close after facet refreshes **/ | |
add_action( 'wp_head', function() { ?> | |
<script> | |
(function($) { | |
$(document).on('facetwp-loaded', function() { | |
if (FWP.loaded && $('.facetwp-flyout').hasClass('active') ) { | |
FWP.flyout.close(); | |
} | |
}); |
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
add_action( 'wp_head', function() { | |
?> | |
<script> | |
(function($) { | |
$(function() { | |
if ( 'undefined' !== typeof FWP && 'undefined' !== typeof FWP.hooks) { | |
FWP.hooks.addFilter('facetwp_map/fit_bounds', function( fit_bounds ) { | |
if ( FWP.loaded ) { | |
return fit_bounds; | |
} else { |
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 | |
/* | |
Plugin Name: FacetWP Schedule Indexer | |
Plugin URI: https://facetwp.com/ | |
Description: Runs indexer periodically by cron | |
Version: 1.0 | |
Author: FacetWP, LLC | |
*/ | |
add_action( 'fwp_scheduled_index', 'fwp_scheduled_index' ); |
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
/** | |
* Use a default label in the open fselect dropdown different from the default shown when closed | |
* change facetwp-facet-product_categories to name of your facet and Custom Label to the label you want to use | |
**/ | |
add_action( 'wp_head', function() { ?> | |
<script> | |
(function($) { | |
$(function() { | |
if ('object' !== typeof FWP) { | |
return; |
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 | |
/** creates a space seperated list of terms (instead of links) for use in | |
** dynamic tags for outputting a css class | |
**/ | |
add_action( 'facetwp_builder_item_value', function( $value, $item ) { | |
if ( 'product-categories' == $item['settings']['name'] ) { | |
$value = ""; | |
$terms = wp_get_post_terms( get_the_ID(), 'product_cat' ); | |
if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) { | |
foreach ( $terms AS $term ) { |
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
<? | |
/** | |
** keeps facetwp conditional's frontend assets from loading | |
**/ | |
add_action( 'wp_footer', function() { | |
wp_dequeue_style( 'fwpcl-front' ); | |
wp_dequeue_script( 'fwpcl-front' ); | |
}, 11 ); |
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 | |
/** always ignore archive query as main query for facet **/ | |
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) { | |
if ( $query->is_archive() && $query->is_main_query() ) { | |
$is_main_query = false; | |
} | |
return $is_main_query; | |
}, 10, 2 ); |