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 trialUnsubscribed User
7,386 Pointsfunction my_plugin_styles and enque the admin stylesheet. (Don't they mean enqueue?)
I don't understand what I'm doing wrong. Why isn't there a blueprint for this? Why must the always change the names around? Sorry, I'm just irritated.
<?php
// Handle: my_plugin_css
// Plugin folder: my-plugin
// CSS file: my-plugin.css
function my_plugin_styles ( ) {
wp_enqueue_styles (‘my_plugin_styles’,plugins_url(‘my-plugin/my-plugin.css’) );
}
add_action (‘admin_head’, ‘my_plugin_styles’ );
?>
2 Answers
Stanley Thijssen
22,831 PointsMake sure you check the comments above your code. It gives you the handle aswell and you used the wrong handle. Also make sure you use wp_enqueue_style() instead of wp_enqueue_styles().
The difference in names is because most of the time there are multiple css files with different file names so the names in the enqueue function are different to point out to those different css files.
function my_plugin_styles() {
wp_enqueue_style('my_plugin_css', plugins_url('my-plugin/my-plugin.css') );
}
Unsubscribed User
7,386 PointsThank you... I'll try it. I just wonder why the direct instructions from TeamTreehouse are 'styles' (plural).