What is the best way to link to a CSS file in WordPress?
Method 1: Use the following whenever needed
<link href="<?php echo get_template_directory_uri(); ?>/my-style.css" rel="stylesheet" type="text/css" />
Method 2: Use enqueue as follows
add_action('wp_enqueue_scripts', 'load_my_style');
function load_my_style () {
wp_register_style('my-style', get_template_directory_uri() . '/my-style.css');
wp_enqueue_style('my-style');
}
Please also let me know why a certain method is better than the other.
Thanks.
EDIT
And for style.css, should I use method 1 or method 2?