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:

Discover more from Juzhax Technology

Subscribe now to keep reading and get access to the full archive.

Continue reading