woof_counter_method
For experiments of developers about memory overloading in Dynamic recount.
- This hook uses in file: wp-content\plugins\woocommerce-products-filter\classes\counter.php
- In __constructor of class WP_QueryWoofCounter
- When this hook returns TRUE in WP_Query attributes is added: nopaging=false and posts_per_page=1 – in some cases this helps to decrease memory consumption, but doesn works for all sites.
From v.1.1.8/2.1.8
Parameters
$saving_memory (bool) — false by default
Source File
classes/counter.php
Code Example
add_filter('woof_counter_method', function($saving_memory) {
// Enable memory-saving counter mode (may be less accurate but faster)
return true;
});
Usage Notes
- Add this code to your theme's
functions.phpfile or a custom plugin. - The hook is applied during the filtering process — changes take effect immediately.
- Always return the expected value type from the callback function.
