web-profile

wp_enqueue_style

Add and load a new style. Version is used to force reload the style and not using cached style, because "style.css?ver=1.0" is different than "style.css?ver=2.0".

<?php
// Inside a parent theme
wp_enqueue_style( 'my-style', get_template_directory_uri() . '/css/my-style.css', false, '1.0', 'all' );
// Inside a child theme
wp_enqueue_style( 'my-style', get_stylesheet_directory_uri() . '/css/my-style.css', false, '1.0', 'all' );
// Inside a plugin
wp_enqueue_style( 'my-style', plugins_url( '/css/my-style.css', __FILE__ ), false, '1.0', 'all' );
?>
<?php
function add_scripts_frontend() {
	wp_enqueue_style( 'my-style', get_template_directory_uri() . '/css/my-style.css', false, '1.0', 'all' );
}
add_action('wp_enqueue_scripts', 'add_scripts_frontend');
?>

Leave a Reply

Your email address will not be published.