Skip to content

Instantly share code, notes, and snippets.

@vanaf1979
Last active January 3, 2020 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanaf1979/6930f53d592fc464a91151a25f5b9343 to your computer and use it in GitHub Desktop.
Save vanaf1979/6930f53d592fc464a91151a25f5b9343 to your computer and use it in GitHub Desktop.
Add a action to enqueue stylesGist for my "WorpdPress: Css Styles and Javascripts in theme development (In depth)" article: https://since1979.dev/wordpress-css-styles-and-javascripts-in-theme-development-in-depth/
<?php
function my_theme_enqueue_styles()
{
wp_enqueue_style( 'my-theme-purecss', 'https://unpkg.com/purecss@1.0.0/build/pure-min.css', array(), '1.0.0', 'screen' );
wp_enqueue_style( 'my-theme-purecss-ie8' , 'https://unpkg.com/purecss@1.0.0/build/grids-responsive-old-ie-min.css', array() , '1.0.0' , 'screen' );
wp_style_add_data( 'my-theme-purecss-ie8' , 'conditional' , 'lte IE 8' );
wp_enqueue_style( 'my-theme-purecss-ie9' , 'https://unpkg.com/purecss@1.0.0/build/grids-responsive-min.css', array() , '1.0.0' , 'screen' );
wp_style_add_data( 'my-theme-purecss-ie9' , 'conditional' , 'gt IE 8' );
wp_enqueue_style( 'my-theme-styles', get_template_directory_uri() . '/style.css', array(), '1.0.0', 'screen' );
/* Add some inline styles */
wp_register_style( 'my-theme-inline-css', false );
wp_add_inline_style( 'my-theme-inline-css', '* { color: red; }' );
wp_enqueue_style( 'my-theme-inline-css' );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment