I have this code in my functions.php
file that should add the version number to both css and js files like for example ..../scripts.js?ver=1664475399
. But it only works with js files. The css file is showing the wordpress version at the end of its name ex. ?ver=6.0.2
function name_enqueuer($my_handle, $relpath, $type='script', $my_deps=array(), $in_footer) {
$uri = get_theme_file_uri($relpath);
$vsn = filemtime(get_theme_file_path($relpath));
if($type == 'script') wp_enqueue_script($my_handle, $uri, $my_deps, $vsn, $in_footer);
else if($type == 'style') wp_enqueue_style($my_handle, $uri, $my_deps, $vsn);
}
/* Add styles */
function name_enqueue_styles() {
wp_enqueue_style( 'style', get_template_directory_uri() . '/dist/css/main.css');
}
add_action( 'wp_enqueue_scripts', 'name_enqueue_styles');
/* Add scripts */
function name_enqueue_scripts() {
name_enqueuer('my-scripts', '/dist/js/scripts.js', 'script', '1.0', true);
}
add_action( 'wp_enqueue_scripts', 'name_enqueue_scripts');
what could cause this problem?
2
Answers
add it to the function
}
wp_enqueue_style( ‘site-css’, get_template_directory_uri() . ‘/assets/css/style.min.css’, array(), get_mod_time(get_template_directory_uri() . ‘/assets/css/style.css’), ‘all’ );