0

I apologize in advance if this question has been asked before.

I've created a plugin, and I'm trying to add an external stylesheet, but it's not working. Am I suppose to compress the plugin file and the stylesheet, and upload them then add a link to the stylesheet in the theme's php file?

1
  • please describe what u have tried in code till now.
    – Zammuuz
    Commented Jul 15, 2014 at 11:01

1 Answer 1

1

I'm assuming your plugin is working, you just don't get the stylesheet stuff to work?

In that case, you can use the wp_enqueue_scripts action.

http://codex.wordpress.org/Function_Reference/wp_enqueue_style#Using_a_Hook

For usage with a stylesheet in the pluginfolder, you can use it like this:

function my_plugin_name_scripts() {
    wp_enqueue_style( 'my-plugin-custom-styles', plugins_url('custom-styles.css' , __FILE__ ) );
}

add_action( 'wp_enqueue_scripts', 'my_plugin_name_scripts' );

Happy Coding, Kuchenundkakao

3
  • Thank you for your response! Yes my plugin is working, i tried following your instructions and I continue to receive a "Fatal error" whenever i try to incorporate the stylesheet
    – jude
    Commented Jul 15, 2014 at 15:18
  • What exactly is the Fatal Error saying? Commented Jul 15, 2014 at 17:46
  • Since it is a plugin so he should be hooking into more appropriate action.
    – gurung
    Commented Aug 25, 2015 at 5:53

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.