自定义边栏中的Woocommerce产品过滤器

时间:2020-10-19 18:42:27

标签: php wordpress woocommerce

我已经注册了一个自定义边栏,该边栏将在Woocommerce类别页面上的商店循环之前显示:

add_action( 'widgets_init', 'extra_widgets' );
function extra_widgets() {
register_sidebar( array(
    'id'            => 'custom_sidebar',
    'name'          => __( 'Custom Sidebar', 'themename' ),
    'before_widget' => '<div>',
    'after_widget'  => '</div>',
    'before_title'  => '<h3 class="widgettitle">',
    'after_title'   => '</h3>'
) );
}

add_action( 'woocommerce_before_shop_loop','display_custom_sidebar' );
function display_custom_sidebar() {
if ( is_active_sidebar( 'custom_sidebar' ) ) {
    dynamic_sidebar( 'custom_sidebar' );
}
}

这是可行的,但是当我尝试添加Woocommerce原生产品属性过滤器时,该过滤器无法正确显示,并且无法正常工作:每个选项之前都没有选中或取消选中的框,它们仅显示为常规链接。我该如何更改代码,以便可以像在常规的Woocommerce侧边栏中显示产品过滤器一样显示产品过滤器?

0 个答案:

没有答案