This can happen if the function for enqueueing stylesheets, wp_enqueue_style()
is run inside functions.php outside of a hooked function, like this:
<?php
wp_enqueue_style( 'my-style', get_stylesheet_uri() );
functions.php is loaded on the front-end and back-end when your theme is active, so this will load the stylesheet in both places.
To only load a stylesheet on the front-end you need to run this function inside another function that is hooked to the wp_enqueue_scripts
hook:
<?php
function wpse_341512_enqueue_styles() {
wp_enqueue_style( 'my-style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'wpse_341512_enqueue_styles' );
By doing this, wp_enqueue_style()
is only run when wpse_341512_enqueue_styles()
is run, and using add_action()
like this queues up that function to only run on the front-end.
Related Posts:
- How do i use fontawesome icons in TinyMce editor?
- Gutenberg Block Editor Match Admin Styles & Frontend Styles
- Deregister CSS style link ‘open-sans-css’
- Different css rules for TinyMCE and Gutenberg while using add_editor_style()
- Load in wp admin assets from child theme
- Admin pages missing css
- How to enable table overflow scroll? (especially order list table)
- How to disable the hover effect in WordPress and Elementor?
- dynamic css file for admin / backend and get_option results in Uncaught Error: Call to undefined function get_option()
- Apply custom css for user role
- Custom css author role
- Button doesn’t work in the profile panel
- ACF Gut block broke wordpress default style?
- WordPress Sudden Loss of All CSS And Tons of JQuery Errors
- How can I add a stylesheet to the Classic Editor page?
- Stop custom Gutenberg styles taking over other admin bits?
- Admin bar default color scheme for nonregistered/nonlogged users
- Lines of CSS only being delivered while logged in
- Adding custom css to a theme depending on whether the admin user is logged in or not
- Change Login CSS – Include instead of echo
- custom css in admin panel by user id
- Enqueue MCE Editor CSS in admin page
- What is WebKit and how is it related to CSS?
- How can I vertically center a “div” element for all browsers using CSS?
- Is there a color code for transparent in HTML?
- How to override the properties of a CSS class using another CSS class
- CSS display: inline vs inline-block
- Aligning two divs side-by-side
- How to center HTML5 Videos?
- Text border using css (border around text)
- Is there an opposite CSS pseudo-class to :hover?
- U8Qtu
- How can I transition height: 0; to height: auto; using CSS?
- Display Images Inline via CSS
- Why CSS3 Animation is not working?
- How to change version of .css in WordPress?
- Why isn’t my theme processing SASS?
- What CSS rules are introduced to core blocks through wp-block-styles?
- Trying to load a responsive CSS media query using Custom Taxonmy
- What is better way to use Bootstrap inside admin panel?
- How to load different css file depending on language
- I want to change my post titles from h2 to H1
- Change logo on specific page id using css
- Write text below a specific part of a sentence
- Style classic editor buttons
- Layer post title on top of image WordPress featured thumbnail image
- Twig + wordpress – how to get filemtime for style.css
- Inconsistent `body_class()` function
- Link theme options page using ACF to styles
- Internet Explorer ignore my css
- Alternate stylesheet only works with absolute address for link?
- Some Text of website page on Iphone Safari become invisible
- Child Theme CSS not showing at all
- Adding CSS to Blog Posts?
- Where do I go to change the position of the style.css?
- Why is my child theme style.css not found (404) in the front-end? [closed]
- wp_enqueue_media is not loading styles
- child theme appears again when I put the header with parent name.
- How to Add a Read-only Textbox With Text in it That Has a Button to Copy it?
- cookie free subdomain and @font-face
- Use Google Fonts and unicodes
- How to add class to an html output element in tinyMCE paragraph drop down menu
- Adding elements to wp_list_pages (within , but before )
- Page versus post ID specific CSS ID?
- Why doesn’t WP recognize images in posts like other content? [closed]
- CSS isn’t rendered on a post but just posted as text [closed]
- How would I create the same popup in css and javascript as the one in contact button on the site https://www.sublimotionibiza.com/es/main.html [closed]
- Customizing the Post/Page Editor in Classic Editor
- CSS for the main top menu appears to have stopped working after All-In-One Migration transfer
- How to use css only H2 Tag? Site is considering website title also H2 tag and changing its style as well
- How to edit CSS style sheet after migrating from local
- Dequeing Parent Fontawesome Deques Parent Styles
- wp_list_pages two columns
- Problems styling a Custom Link in a Menu
- Font .woff files loaded don’t correspond to the displayed styles [closed]
- CSS transition from 0px width to 100% width
- Style not being applied to newly installed themes
- Custom CSS rule overridden in theme
- Twenty Fourteen: Shrinking header while scrolling down
- Style sidebar for a custom page template exclusively
- Make Responsive Specific Page in WordPress
- Custom CSS rules only apply to home page
- Sticky Button not working WP. But does it JS Fiddle
- How to enqueue google fonts if we use directly in style.css
- Trouble with adding preloader to my home page index.html and index.js
- How to change in css with a custom theme?
- Wesbite super slow on iphone / very fast on desktop with same connection on wifi
- WordPress crop image not working [closed]
- How can a left and right margin be added to the admin bar without access to “…wp-includes/admin-bar.php”?
- How to implement styling of div in the front end using plugin admin meta box settings?
- Browser stacks different versions of style.css
- Is it possible to make invisible a div only on certain pages using CSS?
- What CSS selectors to know for WordPress? [closed]
- MY CSS FILE IS MISBEHAVING. IS NOT WORKING WELL ON MY WP SITE [closed]
- Image is very blurry
- Narrow paragraph block aligned to left of “wrapper”
- Transparent Overlay for Gravity Forms Ajax Spinner
- Remove the main title, but only from the main page
- aos properties ‘invalid’ and not recognised when included as a css class [closed]
- ACF Extended : Disable styles in front [closed]