Is there a PHP API for reading the active filters?
Published
Yes, via the FWWLink class – but it must run inside a hook that fires after the URL is parsed (e.g. woocommerce_before_main_content, init or plugins_loaded), never at the top level of functions.php, or it returns blank or white-screens. To read the active filters:
$pm = new FWWLink('', '');
print_r($pm->getfilters()); // e.g. [product_cat] => 2064 [pa_gender] => 2126
if ($pm->getOnSale()) { /* on the on-sale archive */ }
There are also ssf_archive_title and ssf_archive_html filters, and a ssf_widget_query_filter hook to add a SQL condition to the widget counts, e.g. add_filter('ssf_widget_query_filter', function(){ return ' AND p.ID in (1,2,3) '; });. To hide a filter on specific categories, use the free Widget Context plugin, or the widget_display_callback filter (widget id_base ssf_tax_widget).
Still stuck? Post a screenshot on our Discord.
Further reading
every other known problem and its fix.
setting up and configuring the filters.
Comments