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 | |
/** ignore query added by GDPR Cookie Consent **/ | |
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) { | |
if ( 'cookielawinfo' == $query->get( 'post_type' ) ) { | |
$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
// example for product visibility for woocommerce query | |
// hides out of stock | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'product_visibility', | |
'field' => 'name', | |
'terms' => 'outofstock', | |
'operator' => 'NOT IN', | |
), |
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 | |
/** needs to be availble to cron to run **/ | |
function fwp_single_index( $id ) { | |
FWP()->indexer->index( $id ); | |
} | |
add_action( 'fwp_single_index', 'fwp_single_index' ); | |
/** place in whatever function you want to initiate indexing, ex. after running an import **/ | |
wp_schedule_single_event( time(), 'fwp_single_index', array( $post_id ) ); |
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 ( have_posts() ) { | |
do_action( 'woocommerce_before_shop_loop' ); | |
woocommerce_product_loop_start(); | |
while ( have_posts() ) { | |
the_post(); | |
do_action( 'woocommerce_shop_loop' ); | |
wc_get_template_part( 'content', 'product' ); | |
} | |
woocommerce_product_loop_end(); |
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 | |
**/ | |
add_action( 'wp_head', function() { ?> | |
<script> | |
(function($) { | |
$(document).on('facetwp-refresh', function() { | |
if (FWP.loaded && 'recipes' != FWP_HTTP.uri) { // if not the initial pageload, and we're on the homepage | |
window.location.href = '/recipes/?' + FWP.build_query_string(); // redirect |
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
/** | |
** adds click even to each facetwp layout builder result to trigger | |
** a click on the first link within the result | |
**/ | |
add_action( 'wp_footer', function() { | |
?> | |
<script> | |
(function($) { | |
$( '.facetwp-template' ).on( "click", ".fwpl-result", function() { | |
$(this).find('a:first')[0].click(); |
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 elmentor button widget | |
Use link to # | |
Set class in advanced to .facetwp-reset-btn https://d.pr/i/b05YIM | |
Add following js, it can be added in an elementor html code widget (https://d.pr/i/Lat8Z4) | |
if you don't have a theme/plugin setting or custom code you are using | |
--> | |
<script> | |
(function($) { | |
$(document).on('click', '.facetwp-reset-btn', function(e) { |
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 | |
/** re-adds elementor-has-item-radio afer refresh **/ | |
add_action( 'wp_head', function() { ?> | |
<script> | |
(function($) { | |
$(document).on('facetwp-loaded', function() { | |
$('.facetwp-template .elementor-posts-container').addClass('elementor-has-item-ratio'); | |
}); | |
})(jQuery); | |
</script> |