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 trialed quijano
11,907 PointsWhere is the mistake?
The first part of this two step challenge is done. I give you the background of the first part to indicate where I stuck. The first part says, Create an empty function named my_plugin_styles and then use the information in the comment to enque the admin stylesheet. I solved like this and passed // Handle: my_plugin_css // Plugin folder: my-plugin // CSS file: my-plugin.css
function my_plugin_styles(){};
wp_enqueue_style('my_plugin_css', plugins_url('my-plugin/my-plugin.css'));
Now the second part ask "Now hook the function so it displays in the admin area. The way how hook the function is this: add_action('admin_head','my_plugin_styles',); This answer is wrong. Does any body would help me to find where is the wrong part in the las part of this challenge?
5 Answers
srikiran
Courses Plus Student 592 Pointsfunction my_plugin_styles() {
wp_enqueue_style ( 'my_plugin_css' , plugins_url('my-plugin/my-plugin.css') );
add_action('admin_head','my_plugin_styles');
};
Zac Gordon
Treehouse Guest TeacherShouldn't the code you have displayed be inside of the function?
ed quijano
11,907 PointsWell according with your example, this hook needs to be outside from the function. I tried to pun inside of the function but didn't work.
Zac Gordon
Treehouse Guest TeacherYes, the hook call needs to be outside, but the wp_enqueue_style function needs to be inside.
ed quijano
11,907 PointsThanks Zac. It works. But I have one question. When it says, create an empty function, what it means. My my mistake was to create an empty function without nothing inside. I wrote the function and passed. The problem was when I called the hook with the add_action. When I put the function in the wp_enqueue, it works completed. That's why trigger my question.