I am making my first plugin. I create a folder in \wp-content\plugins, create a test.css and a test.php file.

Here is my test.css:

body {
    background-color: red !important;

Here is my test.php (Taken from Theme Developer Handbook):

Plugin Name: Site Plugin for Quảcầu.com
Description: Site specific code changes for Quảcầu.com

function add_theme_scripts() {
  wp_enqueue_style( 'style', get_stylesheet_uri() );
  wp_enqueue_style( 'slider', get_template_directory_uri() . 'test.css', array(), '1.1', 'all');

add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );

But the color doesn't change. Do you know why? Of course I have activated it.

1 Answer 1


Here's your problem:

  wp_enqueue_style( 'style', get_stylesheet_uri() );
  wp_enqueue_style( 'slider', get_template_directory_uri() . 'test.css', array(), '1.1', 'all');

Neither of those files are in your theme. get_stylesheet_uri refers to the style.css that has the themes name etc, and get_template_directory_uri is the URL of the parent theme. Neither of those are your plugin folder.

You can confirm this by looking at the browser dev tools and seeing an error in the console that it tried to load a test.css from your themes folder and failed.

Instead use plugins_url.


plugins_url( 'images/wordpress.png', __FILE__ )

Where the first parameter is the path to the file in your plugin folder, and the second parameter is the main plugin file location on the server.

So this:

get_template_directory_uri() . 'test.css'


plugins_url( 'test.css', __FILE__ );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.