0

I have this function:

function test_add_my_stylesheet() {
    wp_register_style( 'test-admin-style', plugins_url('../css/style.css', __FILE__) );
    wp_enqueue_style( 'test-admin-style' );
}

but the css is not loaded in my admin area. Why?

In the html source code from the browser it looks like this:

<link rel='stylesheet' id='test-admin-style-css'  href='http://www.******.com/wp-content/plugins/******/includes/../css/style.css?ver=3.6.1' type='text/css' media='all' />

instead of:

<link rel='stylesheet' id='test-admin-style-css'  href='http://www.******.com/wp-content/plugins/******/css/style.css?ver=3.6.1' type='text/css' media='all' />

Why is that?

how can I fix this part:

/plugins/*******/includes/../css/style.css

to the correct one:

/plugins/*******/css/style.css
  • I don't see a problem here, the two URLs should fetch the same file. have you actually tried to load the "faulty" url in your browser and see what error do you get? – Mark Kaplun Nov 4 '13 at 10:05
  • Hmm, seems that __FILE__ is causing the problem – Derfder Nov 4 '13 at 11:09
2

plugins_url

plugins_url( $path, $plugin );

You can use:

wp_enqueue_style( 'test-admin-style', plugins_url( 'plugin-unique-name/css/plugin.min.css') );

or you can use

wp_enqueue_style( 'test-admin-style', plugins_url( 'css/admin.min.css', __FILE__ ) );
|improve this answer|||||
0

I am just using

    wp_enqueue_style( 'bootstrap', get_stylesheet_directory_uri() . '/css/bootstrap.min.css');
|improve this answer|||||
  • Please add an explanation to your answer: why could that solve the problem? – fuxia Nov 4 '13 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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