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

Joel Rivera
Joel Rivera
29,401 Points

How to build a wordpress plugin

Can't pass this task and not sure what I'm doing wrong.
Here is the question.
Create an empty function named my_plugin_styles and then use the information in the comment to enque the admin stylesheet. Here is my answer.

<?php

// Handle: my_plugin_css
// Plugin folder: my-plugin
// CSS file: my-plugin.css

function my_plugin_styles() {

wp-enqueue-style( 'my_plugin_styles', plugins_url('my-plugin/my-plugin.css') );

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

?>     

Any tips?

3 Answers

Read the directions. "Create an empty function named my_plugin_styles"

Now look at your my_plugin_styles function. Not empty.

Joel Rivera
Joel Rivera
29,401 Points

Thank you, This is my revised code and it worked.

<?php

// 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'));

?>

Don Shipley
Don Shipley
19,488 Points

It also says and then use the information in the comment to enque the admin stylesheet. which says to me to create the information as we were taught in the video to place this inside of the function......

john hennelly
PLUS
john hennelly
Courses Plus Student 2,831 Points

I had the same problem - the issue is the video is inconsistent with the exercise. 1. in the video the wp_enqueue_style() is wrapped or is part of the the function. 2. the wp_enqueue_style() uses a different parameter set. I had to - which is not a problem - look up doc from wordpress.org to get it to pass.

At least that is how I understand the issue.

Zoe Peng
Zoe Peng
10,809 Points
function my_plugin_styles() {

}
wp_enqueue_style( 'my_plugin_css', plugins_url('my-plugin/my-plugin.css') );