Cannot get Child Theme to load latest version of style.css

In twentyfourteen, try putting this in your child theme:

function add_require_scripts_files() {
 wp_enqueue_style('twentyfourteen-style', get_stylesheet_directory_uri().'/style.css', array(), '1.0.0', "all");        
}
add_action( 'wp_enqueue_scripts', 'add_require_scripts_files' );

This will replace the original stylesheet but with your own version. If you are using a different parent theme, look at the original wp_enqueue_style label for style.css and duplicate that label within your child theme. You will have to change 1.0.0 to another number each time you make a change (so it’s better for production environments where you don’t make changes that often).

To remove the version from scripts and styles all together try this:

// remove WP version tag from scripts and styles, best for dev environments
// by Adam Harley https://wordpress.org/support/topic/enqueueregister-script-remove-version
add_filter( 'script_loader_src', 'remove_src_version' );
add_filter( 'style_loader_src', 'remove_src_version' );
function remove_src_version ( $src ) {
  global $wp_version;
  $version_str="?ver=".$wp_version;
  $version_str_offset = strlen( $src ) - strlen( $version_str );
  if( substr( $src, $version_str_offset ) == $version_str )
    return substr( $src, 0, $version_str_offset );
}

Leave a Comment

tech