Skip to content

Instantly share code, notes, and snippets.

@shameemreza
Created January 28, 2026 05:26
Show Gist options
  • Select an option

  • Save shameemreza/42ca18171ccd00abc6d0588d9562df31 to your computer and use it in GitHub Desktop.

Select an option

Save shameemreza/42ca18171ccd00abc6d0588d9562df31 to your computer and use it in GitHub Desktop.
Disable Product Filters for WooCommerce on search results pages.
<?php
/**
* Disable Product Filters for WooCommerce on search results pages.
*
* This prevents the performance-heavy filter queries from running on search pages
* while keeping filters active on shop, category, and other catalog pages.
*
* @param int|null $filter_id The filter project ID.
* @return int|null The filter ID, or null to disable on search pages.
*
* Usage: Add via Code Snippets plugin, like SnipDrop or child theme's functions.php
*/
add_filter( 'wcpf_default_filter_id', function( $filter_id ) {
if ( is_search() ) {
return null;
}
return $filter_id;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment