According to codex, get_stylesheet_directory_uri()
does not including a trailing slash. So, you might want to use it in the following way:
function wpb_adding_scripts() {
wp_register_script('my_scripts', get_stylesheet_directory_uri().'/js/scripts.js', array('jquery'),'1.1', true);
wp_enqueue_script('my_scripts');
}
add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts' );
UPDATE
If you want to use jQuery in your scripts, you should do it in one of these ways:
- Use
jQuery
instead of$
to avoid conflict - Create a self invoking function and pass
$
to it.
Take a look at this example:
(function($){
$(document).ready(function(){
alert("test");
})
})(jQuery);
Related Posts:
- How to override JavaScript files in child theme?
- How to properly dequeue scripts and styles in child theme?
- Child Theme – what is the scope of overwriting files?
- Enqueue styles properly in a child theme and stylesheets location
- How do I get a child theme to load scripts from the parent theme?
- Is my child theme working properly
- Including style.css in Child Theme
- wp_add_inline_script not adding when script_loader_tag filtered
- Including files in Child Themes
- How to enqueue scripts in order of Head section
- Cannot dequeue script in child theme
- javascript not being enqueued correctly
- Modular CSS and JS in Child Themes
- wp_enqueue wont work on some files?
- Can’t seem to get javascript code working from child theme
- Child theme is not rendering parent and own javascripts (but css loaded properly, js not)
- Enqueuing multiple stylesheets with a child theme
- using a child theme, after enqueing my js file it is loading before jquery
- how to fix loading scripts in child theme?
- WordPress | enqueue_scripts in a child’s theme returns error
- Enqueue Scripts / Styles when shortcode is present
- When should I use wp_register_script() with wp_enqueue_script() vs just wp_enqueue_script()?
- Where is the right place to register/enqueue scripts & styles
- How do I dequeue a parent theme’s CSS file?
- Check if a script/style was enqueued/registered
- Versioning @import of parent theme’s style.css
- How to add code to Header.php in a child theme?
- Why does my child theme CSS get called twice?
- How do themes provide support for child themes?
- Attributing a version number to a child theme’s main stylesheet
- Preserving theme settings in child theme
- Is it possible to make grandchild themes?
- how do I queue my Child stylesheet/s *after* every Parent stylesheet/statement?
- How to cache bust a child theme style.css
- wp_enqueue_scripts, wp_register_scripts, wp_print_scripts: i’m confused
- Is a text-domain necessary for a child theme
- How to modify single.php in a child theme?
- Cannot get Child Theme to load latest version of style.css
- Issues enqueueing parent & child theme stylesheets with revised Codex method
- Register and enqueue conditional (browser-specific) javascript files?
- @package & @subpackage: how to use with child themes
- Correct Method to run scripts with dependencies without enqueue?
- How to override function in child theme
- Cannot deregister a script using wp_deregister_script
- Why is the Child Theme Stylesheet Not Loading?
- Hiding Parent Theme
- Load js/css files only on specific admin UI pages
- get_stylesheet_directory() vs get_template_directory() for child theme
- Theme Customization API and child themes
- How to dequeue / deregister any theme styles and scripts
- get_parent_theme_file_path vs. get_template_directory
- Git vs Child Theme
- Give priority to child theme stylesheet
- Child theme does not overwrite parent themes style.css
- how to call files in child theme?
- Get Parent Theme Author Name
- Enqueue script only when shortcode is used, with WP Plugin Boilerplate
- Get parent theme version
- Hyphens vs. periods in the script slug in wp_register_script?
- Optimal approach for replacing the 8 header images in a child theme?
- jquery script not enqueued in child theme
- How to transfer changes to a child theme?
- WordPress master + child themes + Git workflow
- How to use parent theme’s enqueue methods
- How do I override a parent theme’s language files with a child theme?
- something like is_childtheme()
- Do all files in child theme override the parent?
- wp_register_script multiple identifiers?
- Child theme showing a blank page
- Child theme preview missing
- Child Theme Performance
- enqueue and localize script in footer
- How could child theme be different than parent theme if I haven’t made changes?
- How to solve “Warning: Use of undefined constant” when overriding a parent theme function in the child theme?
- Do I need to update the child theme too after updating the parent?
- get_template_directory vs get_stylesheet_directory
- Adding Custom Javascript to Skeleton Child Theme
- enqueuing React script and hooking its target div fails to load script
- Theme customizer: How do you grab the value later?
- Developing a childtheme, how to disable the parents templates?
- Most elegant way to enqueue scripts in function.php with foreach loop
- How to Add a Custom Script to Customize.php
- Under heavy cache conditions, updating the parent theme don’t reflect changes with child theme enabled
- How to maintain wp_enqueue_style dependencies set in parent theme style enqueuing
- Child Theme, Functions.php Issues
- Redefining function in child themes
- wp_enqueue_script vs. wp_register_script
- Adding scripts to admin page in my theme
- Use js script from one plugin in another plugin
- Pass $this to function nested in another public function of the same class
- How do I check for child theme files first using include, before going to parent theme?
- How can you change default color scheme in a Twenty Fifteen child theme?
- Use admin options from parent theme in child theme
- When activating a child theme, what core settings have to be reset ie; Custom Menus etc?
- Hwo to turn off “get_parent_theme_file_path” in child-theme?
- Best way to enqueue extremely popular scripts like bootstrap and font awesome
- How to dequeue / deregister parent theme style
- Overriding parent theme file
- How to “remove” file from parent theme
- How to override the Parent theme Function into child themes functions.php