Skip to content

Instantly share code, notes, and snippets.

@roelven
Created March 12, 2011 13:31
Show Gist options
  • Save roelven/867234 to your computer and use it in GitHub Desktop.
Save roelven/867234 to your computer and use it in GitHub Desktop.
Load a stylesheet in a Wordpress template in a nice way
// Use this snippet to load a stylesheet in the Wordpress way, accessible to other plugins:
// Credit http://www.nkuttler.de/post/wordpress-style-version-conditional-comments/
if (!is_admin()) {
$theme = get_theme(get_current_theme());
wp_register_style($theme['Template'], get_bloginfo('stylesheet_url'), false, $theme['Version']);
wp_enqueue_style($theme['Template']);
}
// This will look like this:
// <link rel='stylesheet' id='[TEMPLATENAME]-css' href='http://[YOURDOMAIN]/wp-content/themes/[YOURTHEME]/style.css?ver=0.1' type='text/css' media='all' />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment