Created
January 28, 2026 05:26
-
-
Save shameemreza/42ca18171ccd00abc6d0588d9562df31 to your computer and use it in GitHub Desktop.
Disable Product Filters for WooCommerce on search results pages.
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 | |
| /** | |
| * 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