我在模板中使用YITH AJAX PRODUCT FILTER插件。我将小部件放在侧边栏中。当按商店页面过滤产品时,效果很好,但是当分类中的过滤产品消失时,过滤器就会消失。
我注意到,当我在商店页面上使用过滤器时,网址是正确的,例如:myDomain.com/store/?filter_cor=branco&query_type_cor=or
当我在类别页面上使用过滤器时,它会自动重定向到商店页面,例如:myDomain.com/store/?product_cat=blusas&source_id=24&source_tax=product_cat&filter_tamanho=m&query_type_tamanho=or
我正在使用它来创建我的侧边栏:
function awp_widgets_init() {
register_sidebar(array( //try not to enclose this in function
'id' => 'custom_widget',
'name' => 'Woo Widget Filter Category',
'description' => 'A short description of the sidebar.',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
));
}
add_action( 'widgets_init', 'awp_widgets_init' );
Woocommerce.php我正在使用:
<?php if ( is_product_category() || is_shop()) {?>
<aside>
<?php if ( is_active_sidebar( 'custom_widget' ) ) : ?>
<?php dynamic_sidebar( 'custom_widget' ); ?>
<?php endif; ?>
</aside>
<?php } ?>
<div class="col">
<?php woocommerce_content (); ?>
</div>