在WooCommerce FlexSlider中使用点代替移动设备上的缩略图

时间:2020-07-31 07:37:55

标签: php jquery wordpress woocommerce flexslider

我想将WooCommerce FlexSlider更改为使用图库中的点而不是缩略图。但是在台式机上,我想显示缩略图。

我找到了一种解决方案,可以使用点或缩略图,但不能同时在不同的视口中使用它们。

这是我使用缩略图的方法:

add_filter( 'woocommerce_single_product_carousel_options', 'custom_update_woo_flexslider_options' );
function custom_update_woo_flexslider_options( $options ) {

    $options['controlNav']      = 'thumbnails';
    
    return $options;
}

对于点,我将代码更改为此:

    $options['controlNav']      = true;

但是在这种情况下,我必须对所有视口使用其中之一。

有什么办法可以同时使用两者吗?还是每个视口一个?

1 个答案:

答案 0 :(得分:1)

您是否尝试过使用WordPress wp_is_mobile()条件函数,如:

add_filter( 'woocommerce_single_product_carousel_options', 'custom_update_woo_flexslider_options' );
function custom_update_woo_flexslider_options( $options ) {

    $options['controlNav'] = wp_is_mobile() ? true : 'thumbnails';
    
    return $options;
}

可能有效……