How to use internal css in WordPress

One of the way to load CSS in your WordPress plugin. You no need to worry about caching while developing your code and no need to separate one more file.

function my_style_inline() {
  $content = file_get_contents(ABSPATH . 'wp-content/plugins/PLUGINNAME/CSSFILENAME.css');
  echo '<style type="text/css">' . "\n";
  echo $content;
  echo "</style>\n";
}
add_action('wp_head', 'my_style_inline');

Tags:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.