How to use internal css in WordPress

Last updated on April 25th, 2019 at 04:08 pm

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