Skip to content

Instantly share code, notes, and snippets.

@zgordon
Created January 1, 2018 23:42
Show Gist options
  • Save zgordon/af0c59eb368ce838ba41ca783c6f026c to your computer and use it in GitHub Desktop.
Save zgordon/af0c59eb368ce838ba41ca783c6f026c 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