在WordPress中更改默认样式.css的版本

时间:2019-09-30 作者:Elaine Byene

我正在努力Wordpress + Bootstrap 4 根据设计定制。默认样式。css加载为:

<link rel=\'stylesheet\' id=\'wp-bootstrap-starter-style-css\'  href=\'http://localhost/hrone/wp-content/themes/theme_name/style.css?ver=5.2.3\' type=\'text/css\' media=\'all\' />
我想将版本从5.2.3更改为5.2.4或自动更改它的时基。我该怎么做呢?我只有1个css文件,因为这是一个自定义主题。

3 个回复
SO网友:Tom J Nowell

它正在使用5.2.3 因为没有指定版本style.css 已排队/注册。所以它又回到了WordPress的版本。

如果调用时传入版本wp_enqueue_style, 它将使用该值

SO网友:C0c0b33f

在您的功能中。php文件(您使用的是自定义子主题,对吗?)将版本参数更改/添加到wp_get_theme()->get( \'Version\' ) 这将从主题样式中提取版本号。css文件。

https://developer.wordpress.org/reference/functions/wp_enqueue_style/

将此参数设置为false将使用WordPress版本。

wp\\u get\\u theme()返回包含版本的当前主题的主题对象。wp\\u get\\u theme()->parent()->get(\'Version\')将返回父主题版本。

$parent_style = \'wp-bootstrap-starter\';
wp_enqueue_style( $parent_style, get_template_directory_uri() . \'/style.css\', false, wp_get_theme()->parent()->get( \'Version\' ) );

wp_enqueue_style(
    \'child-style\',
    get_stylesheet_directory_uri() . \'/style.css\',
    array( $parent_style ),
    wp_get_theme()->get( \'Version\' )
);

SO网友:Dallas Price

更改样式中的版本号。css文件。

编辑:我误解了。我想这是WordPress的版本。

相关推荐

在充当CSS的PHP中获取ACF选项字段

我使用PHP将所有css文件合并到一个文件中header(\'Content-type: text/css\'); 在处理过的PHP文件中,我想从高级自定义字段中的选项页面中获取一个字段。the_field(\'field_name\', \'option\'); 即使我可以成功调用“header”中部分中的字段。php”,我无法在处理css的php文件中获取它。有没有办法做到这一点?