Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Plugin Specific Styles Not Registering?

Hi everyone :)

Just working on my first plugin, I had the functionality working when the code was tested in my functions.php file prior to making this into a plugin. A that point the css relevant to that function was in the main css directory.

From my main plugin.php file I added the following code hoping it would bring in the css file that is in the same plugin folder as the main plugin.php.

e.g.

-Main Plugin Folder

Plugin.php Plugin.css

<?php

function bf_button_shortcode_styles(){

    wp_enqueue_style( 'bf_button_shortcode_styles', plugins_url( 'bf_button_shortcodes/bf_button_shortcodes.css' ) );

}
add_action( 'admin_head', 'bf_button_shortcode_styles' );

?>

I'm really not sure what I am getting wrong here in respect of loading the css as I have done it in the same way Zac did in the plugin vids...(I think)

Hope you can help :)

Craig

Fixed my own silly issue :)

<?php

add_action( 'wp_enqueue_scripts', 'bf_button_shortcode_styles' );

?>

admin head will style the back end :)

Craig

Never use admin_head in backend as well.... Use admin admin_enqueue_scripts hook otherwise waring may occur...