Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stanwmusic/8527eb77e6fc22d2abb09038a0a359ac to your computer and use it in GitHub Desktop.
Save stanwmusic/8527eb77e6fc22d2abb09038a0a359ac to your computer and use it in GitHub Desktop.
A simple example of Adding CSS to WordPress Theme Via functions.php File
// Load the theme stylesheets
function theme_styles()
{
// Example of loading a jQuery slideshow plugin just on the homepage
wp_register_style( 'flexslider', get_template_directory_uri() . '/css/flexslider.css' );
// Load all of the styles that need to appear on all pages
wp_enqueue_style( 'main', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'custom', get_template_directory_uri() . '/css/custom.css' );
// Conditionally load the FlexSlider CSS on the homepage
if(is_page('home')) {
wp_enqueue_style('flexslider');
}
}
add_action('wp_enqueue_scripts', 'theme_styles');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment