Load a custom.css File From the Theme
Enqueues custom.css from the active (child) theme folder if it exists, with a version based on its modification time to bust caches.
Opens WPIDE on
Code
add_action( 'wp_enqueue_scripts', function () {
$path = get_stylesheet_directory() . '/custom.css';
if ( file_exists( $path ) ) {
wp_enqueue_style( 'wpide-custom-css', get_stylesheet_directory_uri() . '/custom.css', array(), (string) filemtime( $path ) );
}
}, 20 );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.