Add theme version number to stylesheet url, not WP version

  1. Drivingralle

    I think the automatically added version numbers WP adds to all stylesheet/script urls could be better.

    At the moment the WP version is added if no version is specified by wp_enqueue_style. So now a browser will re-download the stylesheet if WP updates. But it's unnecessary. Also if a theme get's updated, the browser don't get to know it and uses the old css. This can lead to broken layouts.

    I would like to see WP adding the version number of the theme to styles/scripts added by the theme. Styles/scripts added by plugins should get the version number of the plugin. Files added by core shold still use the core-version.

    I use this code in my themes. Doing it automatically, would be more nice.

    // Save same data about the theme into a variable
    $child_my_theme_data = wp_get_theme();

    // Enqueue a CSS style file
    get_stylesheet_directory_uri() . '/style.css',

    Posted: 1 year ago #

RSS feed for this topic


You must log in to post.

  • Rating

    1 Vote
  • Status

    This idea is under consideration