Tagged: child theme
I am doing a child theme and want to load a modified version of avia.js. I have created the “js” folder inside my child theme folder and put inside my avia.js but theme is still loading parent theme instead of mine.
Can you help me?
Hi mlabayru!
Insert this code into the child theme functions.php file.
if(!is_admin()) add_action('wp_enqueue_scripts', 'avia_register_child_frontend_scripts', 100);
function avia_register_child_frontend_scripts()
{
$child_theme_url = get_stylesheet_directory_uri();
wp_dequeue_script('avia-default');
//register js
wp_register_script( 'avia-default-child', $child_theme_url.'/js/avia.js', array('jquery'), 1, true);
wp_enqueue_script( 'avia-default-child' );
}
and place your modified js file into the child theme folder (enfold-child/js/avia.js)
Best regards,
Peter
Thank you, that worked perfectly.