For your purpose enqueue is the key:
You can consult this question: How to enqueue the style using wp_enqueue_style() for style enqueue.
For scripts enqueue I recently did as:
// ENQUEUE JAVASCRIPTS FOR CUSTOM PURPOSE
function scripts_for_something() {
wp_register_script( 'my-scripts', get_template_directory_uri() . '/js/my-scripts.js' );
wp_enqueue_script( 'my-scripts' );
}
add_action( 'admin_enqueue_scripts', 'scripts_for_something' );
admin_enqueue_scripts
will enqueue the scripts in the admin panels only. You can use wp_enqueue_scripts
instead for front-end.
Related Posts:
- JavaScript Loading Screen while page loads
- Click button copy to clipboard
- How to make html table vertically scrollable
- How to make Bootstrap carousel slider use mobile left/right swipe
- bootstrap 3 navbar collapse button not working
- How to center image in carousel
- Can Twitter Bootstrap alerts fade in as well as out?
- Play/pause HTML 5 video using JQuery
- jQueryUI dialog width
- Random background images CSS3
- How do I remove a box-shadow effect from an element when another element is hovered?
- Slide right to left?
- Automatically decrease font size for long words
- Best approach for loading a sidebar Only if the screen max-width is >900px?
- Twitter Bootstrap Use Collapse in Custom Post Type
- Stylizing external SVG files with jQuery and CSS
- Gravity list field override and adding javascript [closed]
- Add a class to posts in increments of 2
- Override theme style with other CSS on a specific page
- How can I make this custom menu work?
- Remove WordPress scripts
- How to make an WordPress element sticky? [closed]
- Accordion scrolls page too low after clicking on the title [closed]
- show/hide div with simple jQuery script [closed]
- What is the propre way to include jQuery UI Datepicker’s CSS in plugin?
- Superfish Menu Not Loading
- Problem Implementing parallax in header of bp-default theme
- Is it OK combined wp-include js, jquery, css? [closed]
- jQuery Drill Down iPod Menu FOUC and Selecting Current page
- jQuery Validation plugin and Bootstrap 4 CSS classes
- Getting click on item to open closest relevant element (popup) with jQuery
- How Do I change Markup of a link in WordPress
- jQuery for Fade Preload Causes My Site Favicon to Disappear from Tab of Browser
- Lightbox scroll page down on iPhone
- jQuery function not working in WordPress but works in jsfiddle
- Site images are fixed in front of my site content [closed]
- WP Media Uploader modal conflicts with Bootstrap modal
- :first-child applying to all links [closed]
- How to update scrollbar when using Jetpack’s Inifnite Scroller?
- Hide input field when second input field is in focus
- change the icon of a custom post type in WordPress to use twitter boostrap
- Drop Down Category Menu Not Working
- controlling the showing and hiding of the website logo
- can’t make jQuery work (change image on time interval) [closed]
- JSON parsing error syntax error unexpected end of input
- Change Placeholder Text using jQuery
- $(document).on(“click”… not working?
- how to loop through JSON array in jQuery?
- jQuery – how to write ‘if not equal to’ (opposite of ==)
- Why is jquery show() not working in example
- Get element type with jQuery
- Check if user is logged in using JQuery
- I want to enqueue a .js file to my child theme
- How to prevent WordPress from loading the jQuery library at the top of the page
- Adding jquery and thickbox to WordPress theme
- WooCommerce single product edit flexslider settings
- jquery & ajax getting data to php in wordpress
- AJAX returns response 0
- WordPress Featured Post Slider
- possible to make sections in theme customizer sortable and saveable at publish button clicked?
- Unable to run jQuery script in my template file
- How disable checkbox when listbox value changes in tinymce
- validate a metabox based on the category that is selected
- wp_mail very slow
- Unable to uncheck checkbox with jquery in wp admin
- Front-end Ajax File Upload
- jQuery ajax call throws an HTTP 302
- Sorting widget control
- Plugins loading multiple copies of JQuery
- How to wp_enqueue_script jQuery inside a Plugin
- Cannot enqueue jQuery correctly using Google CDN
- jQuery accordion plugin won’t work once used in WP
- Why use admin-ajax.php when loading pages through AJAX?
- Insertng HTML and jQuery into a page that uses the Defaut template
- WP Rest Api / Ajax POST not working when not logged in
- Admin side jquery is not loaded
- change order of add_action hooks for jquery to be loaded first
- Can’t delete the default jQuery in the theme
- WordPress jQuery crash [closed]
- Conditional Tags – Multiple Categories
- Using Jquery submit with ajax request
- Adding Widgets to Masonry Layouts Correctly – jQuery &&|| PHP
- ajax not working in plugin
- How to Remove Active css from woocommerce variation?
- How to remove jquery migrate on selected posts
- wp not defined at wp.Uploader.prototype
- How to update WordPress jQuery version?
- Unable to use Datepicker in a table when inserting a row
- How to use $ with externally loaded javascript
- wordpress ajax upload media not working
- Bootstrap with separate js File
- How to get this jQuary script working?
- Possibility of creating a folder in the wordpress root install and installing a file there, all via plugin?
- Disable drag metaboxes, create many functions using js not to work!
- value not saving in the form when dynamically creating an input
- wordpress plugin setting page not enqueueing jquery?
- Customize wp-admin form custom fields
- Create a short code that inserts js
- Why I am getting double jquery?
- WP Supersized & Easy Fancybox Conflict