Gists

2 days ago
<?php
/**
 * The template for rendering the product archive page content, customized for facetwp compatibility
 * save to your child theme - childthemename/bigcommerce/components/catalog/product-archive.php
 *
 * @var string[] $posts
 * @var string   $no_results
 * @var string   $title
 * @var string   $description
 * @var string   $refinery
 * @var string   $pagination
 * @var string   $columns
 * @version 1.0.0
 */
?>
<div class="bc-product-archive">

	<header class="bc-product-archive__header">
		<h2 class="bc-product-archive__title"><?php echo esc_html( $title ); ?></h2>
		<div><?php echo wp_kses_post( $description ); ?></div>
	</header>

	<?php echo $refinery; ?>

	<section class="facetwp-template bc-product-grid bc-product-grid--archive bc-product-grid--<?php echo esc_attr( $columns ); ?>col">
		<?php
		if ( ! empty( $posts ) ) {
			foreach ( $posts as $post ) {
				echo $post;
			}
		} else {
			echo $no_results;
		}
		?>

	<?php echo $pagination; ?>
        
	</section>

</div>
5 days ago
<?php

// Add to your (child) theme's functions.php

add_action( 'wp_head', function() {
?>

<script>
// Paste the javascript code here!
</script>

<?php
}, 100 );
5 days ago
<?php
/** adds a facetwp_is_main_query filter to fix compatibility with
 ** Ultimate GDPR & CCPA Plugin plugin
 ** prevents facet from identifying the ct_ugdpr_service used
 ** by the plugin as the main query for filtering
 **/
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
    if ( 'ct_ugdpr_service' == $query->get( 'post_type' ) ) {
        $is_main_query = false;
    }
    return $is_main_query;
}, 10, 2 );
1 week ago
<?php

// Add to your (child) theme's functions.php

add_filter( 'facetwp_facet_filter_posts', function( $result, $params ) {
    if ( 'categories' == $params['facet']['name'] ) {
        return 'continue'; // prevent facet from being processed
    }
    return $result;
}, 10, 2 );
2 weeks ago
<?php

// Add to your (child) theme's functions.php

add_action( 'wp_head', function() {
?>
<script>
(function($) {
    $(function() {
        if ('object' != typeof FWP) return;

        FWP.hooks.addFilter('facetwp/flyout/facet_html', function( facet_html ) {
            return facet_html.replace('<h3>{label}</h3>', '<p>{label}</p>');
        });
    });
})(jQuery);
</script>
<?php
}, 100 );
2 weeks ago
<?php

// Add to your (child) theme's functions.php
add_action( 'pre_get_posts', function( $query ) {
    if ( $query->is_post_type_archive( 'resource' ) ) {
        $query->set( 'orderby', 'title' );
        $query->set( 'order', 'ASC' );
    }
});
2 weeks ago
<?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 );
2 weeks ago
<?php

// Add to your (child) theme's functions.php

add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
    if ( 2 === (int) $query->get( 'posts_per_page' ) ) {
        $is_main_query = false;
    }
    return $is_main_query;
}, 10, 2 );
1 week ago
<?php
// 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',
    ),
),

// other terms: 'exclude-from-search', 'exclude-from-catalog', 'featured', 'outofstock'
// ref: https://wordpress.stackexchange.com/questions/231118/wp-query-exclude-hidden-products-from-woocommerce-product-list
4 weeks ago
<?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();
	do_action( 'woocommerce_after_shop_loop' );
} else {
	do_action( 'woocommerce_no_products_found' );
}
?>