All my enqueued styles are applied to the back-end as well. I have never encountered this behavior before.
Here’s my code:
wp_register_style( 'main-styles', get_stylesheet_directory_uri() . '/css/styles.css', false, '1.0.0', 'all');
wp_enqueue_style('main-styles');
Assuming that is all of the code, it is because you are enqueueing the styles globally. You need to hook that to
wp_enqueue_scripts
, which will only load on the front end.You can register globally or put that
wp_register_scripts
part inside theenqueue_script_front_wpse_84975
function, but you need to hookwp_enqueue_style
, at least, towp_enqueue_scripts
or you will enqueue the stylesheet everywhere. I realize it seems weird to enqueue a stylesheet on a hook ending in “script” but that is correct per the Codex.wp_enqueue_style
can be, and is, used to enqueue anywhere, front or back end, as you can see on the Codex page foradmin_enqueue_scripts
Where are you hooking these?
If you look at the codex, you should add these to a function and hook the function to
wp_enqueue_scripts
for front end display.Example: