Skip to content

Instantly share code, notes, and snippets.

@sergeliatko
Last active October 30, 2017 10:18
Show Gist options
  • Save sergeliatko/8242f89c90fcb879abefaaedf7bf5fae to your computer and use it in GitHub Desktop.
Save sergeliatko/8242f89c90fcb879abefaaedf7bf5fae to your computer and use it in GitHub Desktop.
How to add inline styles to theme stylesheet in WordPress
<?php
/**
* Adds extra CSS rules to the HEAD html tag after to your theme stylesheet.
*/
function my_extra_css() {
wp_add_inline_style(
sanitize_title_with_dashes( wp_get_theme()->get( 'Name' ) ),
'/*** YOUR CSS HERE ***/'
);
}
add_action( 'wp_enqueue_scripts', 'my_extra_css', 10, 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment