Skip to content

Instantly share code, notes, and snippets.

@esedic
Last active January 31, 2025 12:12
Show Gist options
  • Save esedic/5d02372b537bffc5d71e1f8ac4f534ed to your computer and use it in GitHub Desktop.
Save esedic/5d02372b537bffc5d71e1f8ac4f534ed to your computer and use it in GitHub Desktop.
Set timestamp to Wordpress child theme custom CSS file
<?php
function my_child_theme_enqueue_styles() {
$css_file = get_stylesheet_directory() . '/css/style.css';
$css_url = get_stylesheet_directory_uri() . '/css/style.css';
wp_enqueue_style(
'child-style',
$css_url,
array(), // No dependencies
file_exists($css_file) ? filemtime($css_file) : null // Adds timestamp version
);
}
add_action('wp_enqueue_scripts', 'my_child_theme_enqueue_styles');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment