Wordpress: Not able to retrieve css for new plugin in admin mode

Posted by Steven on Stack Overflow See other posts from Stack Overflow or by Steven
Published on 2010-06-08T20:07:18Z Indexed on 2010/06/08 20:12 UTC
Read the original article Hit count: 259

Filed under:
|
|

I'm creating a new plugin which will have it's own css file. The css file resides in the root folder of the plugin.

In the plugin section of the admin interface, I have added a few text fields fields. But the CSS is not applied.

I'm adding the CSS file using this code:

  // Register styling
  add_action('admin_init', 'event_styles');
  function event_styles() {
    wp_register_style('event_cal', plugins_url('eventcall.css',__FILE__));
    wp_enqueue_style('event_cal');    
  }

The following code gives me the CSS path:

echo plugins_url('eventcall.css',__FILE__);

and outputs

http://mysite.com/wp-content/plugins/wp-eventcal/eventcall.css 

If I try to enter this URL directly in the browser, it only shows me the front page.

And if I look in the source code using Firebug, where the link to the CSS should be, I only find the entire HTML code for the front page.

Am I using wrong code to use backend in admin interface? In my HOST file, I have added ``

© Stack Overflow or respective owner

Related posts about php

Related posts about css