【问题标题】:Wordpress custom css doesn't load on iOSWordpress 自定义 CSS 无法在 iOS 上加载
【发布时间】:2019-01-04 15:17:44
【问题描述】:

我尝试自定义子主题的 css。

如果我修改了子主题的style.css,在iOS设备上会被注释掉。 然后我尝试将一个新样式表加入队列,结果是这个样式表根本没有出现在 head 部分中(总是在 iOS 上,桌面版本就像一个魅力)。

这是我将样式表排入队列的代码:

function wp_enqueue_styles() {
    $handle       = 'custom_style';
    $path         = get_stylesheet_directory_uri() . '/css/';
    $directory    = get_stylesheet_directory() . '/css/';
    $dependencies = [];
    $version      = '1.0';

    $filename     = 'main.css';
    $filename_min = 'main.min.css';

    if ( file_exists( $directory . $filename_min ) ) {
        wp_register_style( $handle, $path . $filename_min );
        wp_enqueue_style( $handle, $path . $filename_min, $dependencies, $version );
    } else if ( file_exists( $directory . $filename ) ) {
        // override version with file changed time to bypass cache problems
        wp_register_style( $handle, $path . $filename );
        wp_enqueue_style( $handle, $path . $filename, $dependencies, $version );
    }
}

有什么想法吗?

【问题讨论】:

    标签: ios css wordpress wordpress-theming


    【解决方案1】:

    试试看

    function theme_name_scripts() {
        // Remove a CSS file (main theme)
        wp_deregister_style( 'Script_name_id' );
        // Add New a CSS file ( child theme )
        wp_enqueue_style( 'Script_name_id', get_template_directory_uri() . 'Script_path',[],null);
    }
    add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-12
      • 1970-01-01
      • 1970-01-01
      • 2018-01-22
      • 2017-01-12
      • 2018-02-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多