WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to add version of style.css in WordPress like below i can do in Joomla.

<link rel="stylesheet" href="/templates/example/css/style.css?v=1.2">

i know that the style.css will load dynamically. please help me to how to do that.

share|improve this question
up vote 1 down vote accepted

Version number is a parameter of wp_enqueue_style().

Per the Codex, here are all the parameters that wp_enqueue_style accepts.

wp_enqueue_style( $handle, $src, $deps, $ver, $media );

So for example to load a stylesheet with a version number you'd do the following:

function wpa_90820() {
    wp_enqueue_style('my-styles', get_stylesheet_directory_uri() .'/my-styles.css', '', '1.0' );       

add_action('wp_enqueue_scripts', 'wpa_90820'); 
share|improve this answer
when i do this the old style.css is also loading. How to remove it? – Toretto Mar 14 '13 at 12:10
@VinodDalvi what do you mean by handle. i don't know about it ,i m new to wordpress please me. – Toretto Mar 14 '13 at 12:14
@Toretto Either you theme is hard-coding it in header.php or your theme is also enqueing it with a different handle (the first parameter). The solution also depends on if you are directly editing your theme's functions.php or if you've created a child theme. – helgatheviking Mar 14 '13 at 12:15
@Toretto, $handle is shown in my response and also described in the link I provided to the Codex page for wp_enqueue_style please do your homework. – helgatheviking Mar 14 '13 at 12:15
@helgatheviking how can i know the old handler name. – Toretto Mar 14 '13 at 12:18

You can achieve this using one of the following ways :

1) Add following tag in header.php file of the theme.

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>'?v=1.2" type="text/css" media="all" />

2) Add following code in functions.php file of the theme.

function theme_styles()  
  // Register the style like this for a theme:  
  // (First the unique name for the style (custom-style) then the src, 
  // then dependencies and ver no. and media type)
  wp_enqueue_style( 'style-css', get_template_directory_uri() . '/style.css', array(), '1.2', 'all' );
add_action('wp_enqueue_scripts', 'theme_styles');

For more information see this page.

share|improve this answer
when i do this the old style.css is also loading. How to remove it? – Toretto Mar 14 '13 at 12:10
What is the handle of old style.css? – Vinod Dalvi Mar 14 '13 at 12:13
if you are not able to find the handle then just copy and paste the whole style.css url here.. i will get it from there... – Vinod Dalvi Mar 14 '13 at 12:19
Or can you tell me whats your theme name or theme's folder name? – Vinod Dalvi Mar 14 '13 at 12:23
Welcome .... :) – Vinod Dalvi Mar 14 '13 at 12:25

the best way to load css into your wordpress theme is the following code in your functions.php file:

function theme_styles()  
  global $ver_num; // define global variable for the version number
  $ver_num = mt_rand() // on each call/load of the style the $ver_num will get different value
  wp_enqueue_style( 'style-css', get_template_directory_uri() . '/style.css', array(), $ver_num, 'all' );
add_action('wp_enqueue_scripts', 'theme_styles');

This is the right way to load the styles in your theme and also it's the best for staging/testing purposes because each refresh will deliver the updated version of the style.

If you want to avoid the loading 1st way, you can use this shorted version and place the following line into your header.php file and will get the same result:

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); echo '?ver=' . filemtime( get_stylesheet_directory() . '/style.css'); ?>" type="text/css" media="screen, projection" />


share|improve this answer

This is pretty straight up way of getting the version number by calling the function bloginfo($show) twice. First for the stylesheet and secondly for the version number.

<link rel="stylesheet" id="style-css" href="<?php bloginfo('stylesheet_url'); ?>?ver=<?php bloginfo('version'); ?>" type="text/css" media="all" />

Thats all there is to it. Hope that helps or is useful. You can go through all the parameters available and see what you can output with the bloginfo() function.

Ignore my comment since @Ravs has pointed out my error regarding the 'versions' parameter for the bloginfo() function. It does indeed print the Wordpress version number.

share|improve this answer
I think that it is not correct answer because <?php bloginfo('version')?> gives you current wordpress version while question is about append style.css version not wordpress version. – Ravinder Kumar Jun 5 '13 at 23:25
@Ravs thanks for pointing that out. – cazepeda Jun 9 '13 at 2:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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