fb75
July 14, 2016, 1:27pm
1
Hi I’m actually trying to add a jquery plugin for boackground movement into my child-theme.
I put this in my functions.php like suggested for enqueying css and js :
add_action( ‘wp_enqueue_scripts’, ‘func_enqueue_child_styles’, 99);
function func_enqueue_child_styles() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
wp_dequeue_style(‘activello-style’);
wp_enqueue_style( ‘activello-style’,
get_stylesheet_directory_uri() . ‘/style.css’,
array(‘parent-style’)
);
wp_register_script( ‘interactive_bg’, get_stylesheet_directory_uri() . ‘/js/jquery.interactive_bg.min.js’,
array( ‘jquery’ ), ‘1.0.0’, true );
wp_enqueue_script( ‘interactive_bg’ );
wp_register_script('activello_child_js', get_stylesheet_directory_uri() . '/js/activello-child.js',
array( 'jquery', 'intereactive_bg' ), '1.0.0', true );
wp_enqueue_script( 'activello_child_js' );
}
The problem is that my js file (activello-child.js) is not loaded but only the plugin i want to use (interactive_bg.min.js). Any suggestion? Thanks.
movin
July 15, 2016, 1:45pm
2
Hi @fb75 ,
I hope you are well today and thank you for your question.
It seems this may be not working because you have used intereactive_bg in the last wp_register_script instead of interactive_bg
Could you please try using the following code instead?
add_action( 'wp_enqueue_scripts', 'func_enqueue_child_styles', 99);
function func_enqueue_child_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_dequeue_style('activello-style');
wp_enqueue_style( 'activello-style',
get_stylesheet_directory_uri() . '/style.css',
array('parent-style')
);
wp_register_script( 'interactive_bg', get_stylesheet_directory_uri() . '/js/jquery.interactive_bg.min.js',
array( 'jquery' ), '1.0.0', true );
wp_enqueue_script( 'interactive_bg' );
wp_register_script('activello_child_js', get_stylesheet_directory_uri() . '/js/activello-child.js',
array( 'jquery', 'interactive_bg' ), '1.0.0', true );
wp_enqueue_script( 'activello_child_js' );
}
Best Regards,
Movin
fb75
July 16, 2016, 8:05am
3
Hi Movin,
thank you for your attention, I’ve made a syntax error, but it’s still not working after correcting the error.
Maybe should I dequeue jquery script first and register it again?
I don’t know why my custom file is not being loaded but only the jquery plugin.
Thank you again.
movin
July 18, 2016, 8:26am
4
Could you please share me your whole child theme that contains above code so that i can troubleshoot it on my test site?