个性化阅读
专注于IT技术分析

WordPress自定义CSS无法在iOS上加载

我试图自定义子主题的CSS。

如果我修改子主题的style.css, 它将在iOS设备上被注释掉。然后, 我尝试加入一个新的样式表, 结果是该样式表根本没有出现在头部(始终在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 );
    }
}

任何的想法?


#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' );
赞(0)
未经允许不得转载:srcmini » WordPress自定义CSS无法在iOS上加载

评论 抢沙发

评论前必须登录!