Created
January 1, 2018 23:42
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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