When certain conditions are met (e.g. post vs. page or a category is tagged, etc) I would like to load an additional CSS file. This file would, in theory, change link colors. Or perhaps change the background color. Cosmetic changes. My thinking was to add code to functions.php, however, I don't think this is actually adding the CSS page. Even (even though right now there is no conditional, it should always just add this new page).
Help?
/*
* register with hook 'wp_print_styles'
*/
add_action('wp_print_styles', 'add_my_stylesheet');
/*
* Enqueue style-file, if it exists.
*/
function add_my_stylesheet() {
$myStyleUrl = WP_THEME_URL . '/newStyle.css';
$myStyleFile = WP_THEME_URL . '/newStyle.css';
if ( file_exists($myStyleFile) ) {
wp_register_style('myStyleSheets', $myStyleUrl);
wp_enqueue_style( 'myStyleSheets');
}
}
Thank you
wp_print_styles
is administration-page hook. Anyway why don't you handle this in the header.php file using conditional tags?