You’re supposed to enqueue on the wp_enqueue_scripts
event. Placing the function in functions.php
and immediately running it, will make it run on all pages, including the admin area
Here’s an example from the devhub:
/**
* Proper way to enqueue scripts and styles.
*/
function wpdocs_theme_name_scripts() {
wp_enqueue_style( 'style-name', get_stylesheet_uri() );
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );
This hook/action/event fires on the frontend. If you would like to add a style or script to the backend, use the admin_enqueue_scripts
event instead
Related Posts:
- adding custom stylesheet to wp-admin
- How to Layer 7 Load Balance WordPress Backend and Frontend?
- Is there any filter to disable the total fronted in WordPress
- How to wrap admin menus and menu headers in additional divs without modifying the WordPress core?
- WordPress wp-admin suddenly lost its style
- WordPress Error establishing a database connection For Admin login only
- How do you modify CSS files via admin panel?
- Activating Child Theme Breaks Website, Blank Page, Error 500
- How to use Yoast SEO backend in english even if WPLANG variable is not english?
- Get Stylesheet To Showup in WP Admin Panel Editor
- Custom Background-Image not showing up
- How to make the front-end RTL without changing the admin panel language?
- In editor-style.css how can I change background color of title field?
- Can’t call external stylesheet for WordPress admin (using wp_admin_css)?
- List All Enqueued Scripts and Styles
- How to apply a CSS file to my admin pages?
- Admin menu in front-end
- Add styles to wordpress admin on the Page List
- WordPress Child theme fails to override parent theme css
- CSS of the admin panel
- Why does my edit screen suddenly have such a buggy interface?
- Admin area is not loading properly
- is_admin() conditional statement
- CSS not showing up in my website Only HTML Displaying
- Change height of Add New Post input box
- plugin: ‘init’ hook, check if we’re not in admin
- Removing Author name
- theme injecting css into wp-admin
- Where are the Parent themes CSS & PHP files hidden on WordPress?
- Redirect users based on their roles, is_admin()
- How can we make managing lots of pages in WordPress Admin better?
- Show all post tags on post edit screen/sidebox
- Add “external” link to admin menu in the backend
- Disable image attachment links
- Remove “Time to upgrade” message from dashboard
- Change Login URL Without Plugin
- wp-admin pages return ERR_EMPTY_RESPONSE
- Unwanted redirect in admin area
- Looking for a hook to add attachment information to the media library tab
- How to move wp-admin login page to another location? [closed]
- WP-admin giving 404
- How to control contextual help section by code?
- Can’t access wp-admin Internal Server Error 500
- Can’t access dashboard, connection times out (other pages work fine)
- Getting post meta data, while editing a post in wp-admin panel [closed]
- Add custom text to Page Tamplate without need to know html
- Move WP Admin Bar
- Just how ‘expensive’ is this function?
- How to show postmeta in custom columns for the posts screen?
- disable a wp javascript on live website, but not on wp-admin page
- How can I remove the user avatar from admin toolbar?
- How to stop – Database Update Required – from happening again?
- using wp_sprintf at wordpress option page,
- Can’t login to Dashboard when changing site URL to HTTPS
- Limit access to wp_admin
- Not Found (404) error on admin page, CSS gone on blog
- Remove All in One Pack from the admin bar
- Disable wordpress reordering functions in backend screen element
- WordPress server change – slow admin login time for first time
- I can´t access my admin panel. I tried all possible solutions
- Ajax solution similar to WP Categories functioning in Admin area
- Difference between admin and user admin
- Hooks: admin_footer and admin_print_footer_scripts not working?
- Editing edit-tags.php page in wp-admin
- What is the correct way to get only display plugin for Administrator Only
- displaying an error before update_post_meta
- Browse Happy in 3.2
- Outputting something based on the presence of post variable in admin screens
- “Add New” button on custom post type grid
- Where is function to prevents non logged users access wp-admin?
- Dismiss Admin Pointer Temporarily
- WordPress admin right sidebar isn’t working
- WordPress menu to change page title
- wp-admin blocking causing http error on uploads
- Disable some features in Admin
- DISALLOW_FILE_EDIT is false but I still am not able to edit files from the admin interface and the menus do not show up
- Don’t run code if in customizer or privew
- What hooks should you use to create a table only once?
- Redirect WordPress login for customers but not admin
- Cant access wp-admin
- Unable to open specific posts on WP Dashboard [duplicate]
- How to list newly ftp added HTML webpage under Pages section of wp-admin?
- Hi everyone, I have Problem with using wp_die()
- WordPress wp-admin Page
- How can I trigger a javascript function after a post update on edit post screen in wordpress admin panel?
- restrict admin panel sections to users
- how to set not to be logined in wp-admin except administrator?
- Disable flyout (popup) menus in backend
- WordPress, content editor default type
- Random HTTPs redirections at admin area in shared hosting
- WordPress Login for multiple sites
- Blank sign in page
- add_post_meta displays in admin edit area
- Forcing WordPress Administration onto a separate SSL Host
- How to prevent Google adsense invalid impressions while performing admin tasks on my wordpress site?
- Action for opening edit page in admin?
- What is the point of new confirm admin email process?
- ‘Too many redirects’ error after changing site URL in WordPress [closed]
- Is it possible to tell if a user is logged into WordPress from looking at the cookies which are set?
- Extend user search in the Wp backend area on the users.php page to allow for searching by email domain and role from the “users search” input box