admin管理员组

文章数量:1295296

I'm working on Wordpress + Bootstrap 4 by customising according to the design. The default style.css loads as:

<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' />

I would like to change the version from 5.2.3 to 5.2.4 or auto change it time base. How do I go about doing this? I have just 1 css file since this is a custom theme.

I'm working on Wordpress + Bootstrap 4 by customising according to the design. The default style.css loads as:

<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' />

I would like to change the version from 5.2.3 to 5.2.4 or auto change it time base. How do I go about doing this? I have just 1 css file since this is a custom theme.

Share Improve this question asked Sep 30, 2019 at 14:48 Elaine ByeneElaine Byene 1177 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 1

It's using 5.2.3 because no version was specified when style.css was enqueued/registered. So it fell back to the version of WordPress.

If you pass in a version when calling wp_enqueue_style, it will use that value instead

In your functions.php file (you're using a custom child theme, right?) change/add the version parameter to wp_get_theme()->get( 'Version' ) this will pull the version number from your theme's style.css file.

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

Setting this parameter to false will use the WordPress version.

wp_get_theme() returns the theme object for the current theme which contains the version. wp_get_theme()->parent()->get( 'Version' ) will return the parent themes 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' )
);

Change the version number in your style.css file.

Edit: I misunderstood. I think that's the WordPress version.

本文标签: jqueryChange the version of default stylecss in wordpress