This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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($) { | |
$(document).on('facetwp-loaded', function() { | |
if ('' != FWP.build_query_string()) { | |
$('.facetwp-template').show(); | |
} else { | |
$('.facetwp-template').hide(); | |
} |
This file contains hidden or 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 | |
/** basic check to modify robots when facets are selected during pre-load **/ | |
add_filter( 'wpseo_robots_array', function( $robots, $class ) { | |
if ( function_exists( 'FWP' ) && !empty( FWP()->ajax->url_vars ) ) { | |
$robots['index'] = 'noindex'; | |
$robots['follow'] = 'nofollow'; | |
} | |
return $robots; | |
}, 10, 2); |
This file contains hidden or 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 | |
/** | |
* Product Group Template for Bigcommerce modified for FacetWP | |
* add to your_theme/bigcommerce/components/products/product-shortcode-grid.php | |
* @var string[] $cards | |
* @var string $pagination | |
* @var bool $wrap Whether to wrap the output in a div | |
* @var int $columns The number of columns to use for the grid | |
* @version 1.0.0 | |
*/ |
This file contains hidden or 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 | |
/** | |
** for creating custom image sizes | |
** https://developer.wordpress.org/reference/functions/add_image_size/ | |
**/ | |
add_filter( 'facetwp_builder_item_value', function( $value, $item ) { | |
if ( 'my-image' == $item['settings']['name'] && !empty( $value ) ) { // change 'my-image' to the unique name of your field | |
$image = get_field('acf_image_field'); // change 'acf_image_field' to the name of your acf field | |
if ( $image ) $value = wp_get_attachment_image( $image, 'thumbnail' ); // 'thumbnail' can be changed to other image sizes you have available | |
} |
This file contains hidden or 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
.rtl .facetwp-flyout { | |
transform: translateX(100%); | |
} |
NewerOlder