【问题标题】:How to Change FlexSlider options in WooCommerce child theme如何在 WooCommerce 子主题中更改 FlexSlider 选项
【发布时间】:2020-08-20 10:47:39
【问题描述】:

我刚刚更改了 class-wc-frontend-scripts.php 文件的这一部分,该文件位于 Woocommerce 的“includes”文件夹中:

'flexslider' => apply_filters( 'woocommerce_single_product_carousel_options',
    array(
        'rtl'            => is_rtl(),
        'animation'      => 'fade',
        'easing'      => 'swing',
        'smoothHeight'   => true,
        'directionNav'   => false,
        'controlNav'     => true,
        'slideshow'      => true,
        'touch'      => true,
        'animationSpeed' => 1200,
        'slideshowSpeed' => 3500,
        'animationLoop'  => true, // Breaks photoswipe pagination if true.
        'allowOneSlide'  => true,
        'prevText' => "<",           //String: Set the text for the "previous" directionNav item
        'nextText' => ">",               //String: Set the text for the "next" directionNav item
    )
),

如何将其转移到子主题?

【问题讨论】:

    标签: php wordpress woocommerce product flexslider


    【解决方案1】:

    不要覆盖任何核心文件...相反,您可以使用 woocommerce_single_product_carousel_options 过滤器挂钩,如下所示:

    add_filter( 'woocommerce_single_product_carousel_options', 'filter_single_product_carousel_options' );
    function filter_single_product_carousel_options( $args ) {
        $args['animation']      = 'fade';
        $args['easing']         = 'swing';
        $args['controlNav']     = true;
        $args['slideshow']      = true;
        $args['touch']          = true;
        $args['animationSpeed'] = 1200;
        $args['slideshowSpeed'] = 3500;
        $args['animationLoop']  = true; // Breaks photoswipe pagination if true.
        $args['allowOneSlide']  = true;
        $args['prevText']       = "<";  // String - Set the text for the "previous" directionNav item
        $args['nextText']       = ">";  // String - Set the text for the "next" directionNav item
        
        return $args;
    }
    

    代码在您的活动子主题(或活动主题)的functions.php 文件中。它应该可以工作。

    相关:Change FlexSlider options on mobile in Woocommerce

    【讨论】:

      猜你喜欢
      • 2023-03-17
      • 2022-11-20
      • 1970-01-01
      • 2012-02-18
      • 1970-01-01
      • 1970-01-01
      • 2022-08-09
      • 2015-09-29
      • 1970-01-01
      相关资源
      最近更新 更多