0

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.

3 Answers 3

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

4
  • `wp_enqueue_style' creates a new css file which isn't what I want. Commented Sep 30, 2019 at 15:48
  • 1
    You theme already calls wp_enqueue_style() somewhere. You need to specify the version wherever that is. It appears to be line 80 of functions.php in the latest version. Commented Sep 30, 2019 at 16:21
  • I have this in line 80 function wp_boostrap_starter_add_editor_styles() { add_editor_style( 'custom-editor-style.css' ); } add_action( 'admin_init', 'wp_boostrap_starter_add_editor_styles' ); which isn't the style.css but the custom css file. I'm working on style.css. Commented Sep 30, 2019 at 19:10
  • 2
    @ElaineByene wp_enqueue_style does not create new files, and it is style.css because it says so in the HTML of your question, it'll be enqueued as bootstrap-starter-style judging from the id attribute
    – Tom J Nowell
    Commented Sep 30, 2019 at 22:48
0

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.org/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' )
);
-1

Change the version number in your style.css file.

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

1
  • 1
    That’s not where this number comes from. Commented Sep 30, 2019 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.