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 How to Build a WordPress Plugin Building a WordPress Plugin Settings Page Adding CSS to WordPress Plugin Settings Pages

Tim Beckett
Tim Beckett
1,301 Points

Can't get styles to show up, although path is correct.

I'm wondering if there has been an update in how wp_enqueue_style works since this video was made. I've checked the Codex for 'plugins_url', and 'admin_head' and updated accordingly for 'plugins_url'. Yet, stylesheet isn't showing up - I'm not even getting a 404 not found error. This is my code:

function wptreehouse_badges_styles() {

//from lesson wp_enqueue_style( 'wptreehouse_badges_styles', plugins_url( 'wp_plugins_treehouse/css/wptreehouse-badges.css') );

//after checking Codex wp_enqueue_style( 'wptreehouse_badges_styles', plugins_url( 'wp_plugins_treehouse/css/wptreehouse-badges.css', dirname(FILE)) );

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

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Try adding a forward flash / in front of your file path for your plugins_url argument. I've managed to get files enqueued after doing that in the past.

<?php
function wptreehouse_badges_styles() {

//from lesson wp_enqueue_style( 'wptreehouse_badges_styles', plugins_url( '/wp_plugins_treehouse/css/wptreehouse-badges.css') );

} add_action( 'admin_head', 'wptreehouse_badges_styles' );
?>
Tim Beckett
Tim Beckett
1,301 Points

Hi Jonathan,

Thanks for the speedy answer. I tried this to no effect. The funny thing is - I've included stylesheets on other (small) plugins I've built without any problems. This one doesn't seem to work, no matter what I do. Also same effect a few videos forward. Makes me wonder if what these videos are teaching isn't compatible with the latest versions of Wordpress. If so, too bad, as I like the course and Zac's a good teacher, but frustrating when things don't work and you're not sure why.

Best, 

Tim