To enqueue styles and scripts properly, use the wp_enqueue_scripts
action like so:
function wpa_63708_enqueue_scripts() {
wp_register_script( 'my-script','/path/to/script' );
wp_enqueue_script( 'my-script' );
}
add_action( 'wp_enqueue_scripts', 'wpa_63708_enqueue_scripts' );
Related Posts:
- How to Link External jQuery/Javascript files with WordPress
- Display custom_background outside wp_head()
- How to trigger function on theme delete?
- How can I add class to every quote element?
- How to display message (with switch_theme hook) after deactivating My theme?
- What hook is the currently active theme’s functions.php file loaded on? [duplicate]
- after_setup_theme is called three times
- It’s okay if I do not write add_action()
- How to use only scripts from new theme?
- Set custom directory in theme for page templates
- Webflow Interactions on WordPress site?
- Don’t prepend WordPress base url to image paths
- Fatal error Class-wp-hook, again, but not sure what’s triggering it
- Opinions and recommendations on the best barebones base theme [closed]
- How to change the language for the front-end only?
- Different template of products for specific category. WooCommerce
- Switching themes without losing widgets?
- How to use media upload on theme option page?
- WordPress 5 / Gutenberg – theme doesn’t have featured image option showing up
- How to refresh WordPress Customizer panel upon entering a value
- Set Featured Image for Archive templates
- Multiple image logo for theme
- Loading template files from a subfolder in my theme?
- Hide Twenty Eleven Theme From Themes Page
- How do I change Twenty Nineteen’s primary color without using the color slider in the theme customizer?
- How to add the main style.css to my index.php?
- Remove action within a class in a parent theme from the child theme
- Exclude stylesheet from admin
- How to tell a theme to use different .mo and .po files?
- Can I apply a WP theme to a specific custom page template?
- How to move WordPress theme files into a subfolder without breaking the theme?
- remove rel=next on home page but not others
- Is it possible to use child theme of child them?
- Disable Sidebar in the Product Page in Storefront Theme [closed]
- Renaming the Twenty Fourteen WordPress theme
- Defining different theme for Blog posts page
- How to understand a specific bit of WordPress syntax
- How to unset comment_notes_before field in WordPress comment_form
- How do I tell how popular a theme is?
- How to loop over wp_get_themes() and create an array of themes name
- Force theme or disallow theme change
- How to run WordPress from other location on the same domain
- Custom options below pages/posts editor?
- Fatal error with a theme
- WordPress theme options and insert default value for serialize data
- Restrict access to specific widget field based on user role
- Twenty Twelve theme search returns Nothing Found
- How to replace a function using a child theme?
- WooThemes PremiumNews Theme jQuery Conflict with WordPress 3.2
- The Cost of Installing Custom Themes
- Can I create a child theme from a premium theme without losing my posts and page etc that I already have?
- Change copyright text on the footer section [closed]
- wordpress theme install failing
- WordPress suddenly creating theme errors
- Re-skinning Site
- How to reset a custom theme
- Warning : Invalid argument supplied for foreach() in theme php on line 56 [closed]
- Cannot changing login button color, have tried theme, plugins… is it GoDaddy managed?
- Why submenu item’s background color is not changing by css?
- Cannot see theme in my search
- What login/password do I need to install a wordpress theme?
- get_pages Not accepting my query
- Date based CSS/theme
- Functions.php error – when trying to change the theme
- Make a menu item unselectable
- conditional statement if wordpress theme block is empty then hide block
- Getting Post ID at “stylesheet” and “template” hooks
- Can I use non-wordpress themes in WordPress?
- jQuery is not defined – some theme features do not work!
- How can I modify the CSS only for the search results page of WordPress?
- SVG icons in Twenty Nineteen
- Does anyone know where to find the area to edit this text
- fixing page URL’s
- Issues with dynamic widget in theme customizer
- Change name of WP content > Themes folder
- wp_login_form() ignoring login_form action hook
- Theme Dev | Convert Template to Theme
- How to Solve the WordPress Cron Job Site Slow down Problem?
- How do I get the path to the currently in use theme’s directory?
- Pagination not working in home page
- Show part of front page on another page [closed]
- template_redirect and title
- Premium theme – hardcoded url?
- Any Mobile Theme Switcher – Theme not complete (Stylesheet missing)
- permissions on themes directory
- Categorising themes by folders in backend
- Theme Options Menu Item – Permission Issue
- theme 2016 – customize css – nothing happens
- Can’t upload the theme
- Divi theme including javascript
- Best Practice Jumbotron Image for WordPress ~ Responsive
- How to make a page extend full screen [closed]
- Should you directly edit Template Parts and Templates from themes?
- Remove ALL HTML from single page
- Remove Google Fonts from parent theme within a child theme [closed]
- Define a Custom Template Part As A Widget Area
- Changing Sidebar In 2023 Theme
- Absolute and relative paths
- Get header/footer list for a theme
- Help!!! Old theme doesn’t load scripts and conflitcs with plugins