Setup -带有“”(https://docs.woocommerce.com/document/woocommerce-widgets/#section-6)侧栏小部件的C0
主"Shop“页面。
当我选择一个属性时,页面将相应地显示产品(/shop/?filter_name=filter_type)。
当页面显示过滤后的产品列表时,我需要一个检查,即
if (shop_page_is_showing_filtered())
//
elseif (is_shop())
//
这样的东西很好-- 使用属性筛选时显示属性描述 --但是它需要显式地声明属性。我只想知道我的页面是否显示了任何属性。
谢谢!
发布于 2020-05-06 09:44:58
这就是答案:
function active_woocommerce_filters() {
// for older WC versions
// global $_chosen_attributes;
$_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes();
return count( $_chosen_attributes );
}
https://stackoverflow.com/questions/33229238/woocommerce-check-if-filtering-products
https://wordpress.stackexchange.com/questions/365970
复制相似问题