猿问

如何更改 WooCommerce 子主题中的 FlexSlider 选项

我刚刚更改了 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

    )

),

如何将其转移到儿童主题?


繁花如伊
浏览 110回答 1
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 文件中。它应该有效。
随时随地看视频慕课网APP
我要回答