【问题标题】:How to display product filter in custom plugin development如何在自定义插件开发中显示产品过滤器
【发布时间】:2020-01-29 09:02:22
【问题描述】:

我想在我的自定义插件开发中显示默认的 Woo-commerce 产品过滤器。我使用以下短代码来展示产品。

echo do_shortcode("[products]");

它正在工作并且产品也在显示,但我也想在 Woo-commerce 中显示默认产品过滤器,我使用了以下短代码,但默认产品过滤器没有显示。

[woocommerce_product_filter_products]
[woocommerce_product_filter] 

有没有其他方法可以在插件开发或其他页面中显示默认产品过滤器?

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    注册侧边栏:

    if ( function_exists('shortcodeWidget') )
      register_sidebar(array(
        'name' => 'Shortode widget for filter',
        'id' => 'shortcode-widget',
        'before_widget' => '<div class = "filterWidget">',
        'after_widget' => '</div>',
        'before_title' => '<h3>',
        'after_title' => '</h3>',
      )
    );
    

    注册短代码后

    function shortcodeSidebar(){
    
      ob_start();
      get_sidebar('shortcode-widget');
      $sidebar= ob_get_contents();
      ob_end_clean();
    
      return $sidebar;
    }
    
    add_shortcode('filterWoocommerce', 'shortcodeSidebar');
    

    然后在自定义小部件中添加过滤器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-05
      • 1970-01-01
      • 2019-05-29
      • 1970-01-01
      • 2020-08-29
      相关资源
      最近更新 更多