E
E
Evgeny Zhurov2018-06-13 18:01:11
WordPress
Evgeny Zhurov, 2018-06-13 18:01:11

Why is the theme stylesheet loading in the WordPress admin?

Tell me what's wrong?
There is a task to include a css file (but not the theme's default style.css, but style.min.css). And also add the ability to overwrite the version number of the file. I did it like this in functions.php:

wp_enqueue_style( 'style-theme', get_template_directory_uri() . '/style.min.css', array(), '1.0.0', 'all');

And it works, but for some reason it also loads this style.min.css in the admin panel! Because of this, the admin panel swam a little)
What was done wrong and how to fix it? The function runs at the very beginning of functions.php, not inside any other function, i.e. in theory everything is clean.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mr Crabbz, 2018-06-13
@Zhuroff

Well, don’t load the style in the admin panel - it’s business then ...

<?php
if(!is_admin()) { wp_enqueue_style( 'style-theme', get_template_directory_uri() . '/style.min.css', array(), '1.0.0', 'all');
 }
?>

A
Alexey Sklyarov, 2018-06-13
@0example

I'm not 100% ready to say that the right solution will be, but at least fix "style-theme" to style.min

T
tyzberd, 2018-06-13
@tyzberd

https://www.engagewp.com/load-minified-stylesheet-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question