Gists

by djrmom - 2 months ago

<?php
/** for sites that only use facets on woocommerce archive pages -
 ** shop page, product category archives, product tag archives,
 ** any others auto-created by woocommerce
 ** not for [product] shortcode or custom queries
 **/

add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
    if ( 'product_query' != $query->get( 'wc_query' ) ) {
        $is_main_query = false;
    }
    return $is_main_query;
}, 10, 2 );
by djrmom - 5 months ago

<?php
/* only filter woo product query if cpt is product */
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
    if ( 'product' == $query->get( 'post_type' ) && 'product_query' != $query->get( 'wc_query' ) ) {
        $is_main_query = false;
    }
    return $is_main_query;
}, 10, 2 );
by mgibbs189 - 5 months ago

<?php

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

add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
    if ( 'product' == $query->get( 'post_type' ) && 'product_query' != $query->get( 'wc_query' ) ) {
        $is_main_query = false;
    }
    return $is_main_query;
}, 10, 2 );

by mgibbs189 - 11 months ago

<?php

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

add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
    if ( 'da_image' == $query->get( 'post_type' ) ) {
        $is_main_query = false;
    }
    return $is_main_query;
}, 10, 2 );

by djrmom - 1 year ago

<?php

/** makes sure the is_home query defaults to post rather than any post_type **/
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
    if ( is_home() && $is_main_query && empty( $query->get('post_type') ) ) {
        $query->set( 'post_type', 'post' );
    }
    return $is_main_query;
}, 10, 2);
by djrmom - 1 year ago

<?php

add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
	if ( 'search' == FWP()->helper->get_uri() && ! in_array( 'secondary_content', (array) $query->get( 'post_type' ) ) {
		return false;
	}
	return $is_main_query;
}, 10, 2 );
by djrmom - 1 year ago

<?php
/** a query from WP GDPR Compliance plugin gets set as the
 ** main query, this fixes it 
 **/
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
    if ( '[wpgdprc_access_request_form]' == $query->get('s') ) {
        return false;
    }
    return $is_main_query;
}, 10, 2);
by djrmom - 1 year ago

<?php
/* only use queries with facetwp=>true in its args */
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
    if ( true !== $query->get( 'facetwp' ) ) {
        $is_main_query = false;
    }
    return $is_main_query;
}, 10, 2 );
by mgibbs189 - 2 years ago

<?php

// Add to your (child) theme's functions.php
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
    return ( $query->is_post_type_archive( 'petite_annonce' ) ) ? false : $is_main_query;
}, 10, 2 );

by mgibbs189 - 2 years ago

<?php

add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
    return ( $query->is_home() ) ? false : $is_main_query;
}, 10, 2 );