I am trying to add a stylesheet when users are accessing the blog section of my site from and iPad. The first snippet of code works, however, I don't want to use the absolute path. I want to use wordpress's function.
function ipad_css() {
if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT'])) {?>
<link rel="stylesheet" type="text/css" href="http://website/wp-content/themes/my_theme/ipad.css" media="screen" />
<?php }
}
add_action('init','ipad_css');
This doesn't seem to work:
function ipad_css() {
if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT'])) {?>
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/ipad.css" media="screen" />
<?php }
}
add_action('init','ipad_css');
I'm confused as to why it won't work. I have trying stylesheet_url
as well with no luck.