You should never use <link>
tags for stylesheets. Always use the proper API functions:
Better practice Example:
function wpse57423_register_stylesheets()
{
wp_enqueue_style(
"themes_main_stylesheet'
get_stylesheet_directory_uri()."/style.css"
array() // Use this array if you've deps that need to load before your stylesheet
filemtime( get_stylesheet_directory()."/style.css" )
);
}
function wpse57423_enqueue_stylesheets()
{
wp_enqueue_style( 'themes_main_stylesheet' );
}
// Add to public page
add_action( 'wp_enqueue_scripts', 'wpse57423_register_stylesheets' );
add_action( 'wp_enqueue_scripts', 'wpse57423_enqueue_stylesheets' );
// Add to login
add_action( 'login_enqueue_scripts', 'wpse57423_register_stylesheets' );
add_action( 'login_enqueue_scripts', 'wpse57423_enqueue_stylesheets' );
// Add to admin UI/backend
add_action( 'admin_enqueue_scripts', 'wpse57423_register_stylesheets' );
add_action( 'admin_enqueue_scripts', 'wpse57423_enqueue_stylesheets' );
Please note that the login page needs specific treatment. Refer to this answer if you need to handle it.
This allows to
- enqueue/register styles only where you need them and don’t load them everywhere
- child themes the possibility to override your styles with adding a stylesheet with a) the same name in b) the same position in their folder
- deregistering stylesheets in child themes
- unhooking the functions