Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress How to Build a WordPress Plugin Building a WordPress Plugin Settings Page Adding CSS to WordPress Plugin Settings Pages

Avery Kushner
Avery Kushner
854 Points

Can't get the styles to apply to the page

The style shows up under sources in developer tools, but doesn't apply any styles to the html.

Avery Kushner
Avery Kushner
854 Points

Here is my code:

function wptreehouse_badges_styles() {

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

} 

add_action( 'admin_head', 'wptreehouse_badges_styles' );

1 Answer

Sherie LaPrade
PLUS
Sherie LaPrade
Courses Plus Student 4,007 Points

The code in the video is a bit outdated, here is what my sister and I used that works:

function wptreehouse_badges_styles() {

    wp_enqueue_style( 'wptreehouse_badges_styles', plugins_url( 'wptreehouse-badges.css', __FILE__ ) );

}
add_action( 'admin_head', 'wptreehouse_badges_styles' );
Jill Ferron
Jill Ferron
5,023 Points

thanks Sherie, worked for me.