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 trialEvan Fraser
6,789 PointsHow to enqueue custom wordpress theme styles in wordpress admin theme options page
I am building a wordpress theme and I am trying to enqueue styles in the same fashion that I did for my custom wordpress plugin, i am just not sure how.
I did it in my plugin fine but I dont know how to for my theme, its super frustrating, I just cant figure it out. Right now i have them inline inside my functions for my theme but thats just annoying. Anyone have any help for me on this? Im new to php and php for wordpress too by the way.
here is what i did in my plugin (I want to do the same thing for my theme):
function hawp_media_options_styles () {
wp_enqueue_style ( 'hawp_media_options_styles', plugins_url( 'hawp-optimize/hawp-optimize-style.css' ) );
}
add_action ('admin_head', 'hawp_media_options_styles' );
1 Answer
Jacob Mishkin
23,118 PointsI think you'll need to review your path to the css folder in your theme. here is a solid place to start looking how to debug your issue. If you have any questions please ask.
Evan Fraser
6,789 PointsEvan Fraser
6,789 PointsI still am unable to figure out the right function to add in my theme functions.php to style to my theme options page and also a few other things throughout the wordpress admin.
Inside my theme I have a css folder then hawp-theme-admin.css which has all my intended admin styles. If you can give me an example that would be great
Thanks so far!
Jacob Mishkin
23,118 PointsJacob Mishkin
23,118 PointsThere are two possible answers. you need to use either get_stylesheet_directory_uri(), or get_template_directory_uri
codex
In this case depending on the set up of your theme it's going to be one or the other. In the future try and use the dev WordPress code reference. It is linked above.