Tagged: child template, Hamburger-Menu, javascript, jQuery, override, overwrite
-
AuthorPosts
-
October 27, 2021 at 12:12 am #1326553
Hello,
i am unable to override a template file from the main theme folder.
The code works in parent folder but it doesnt work when i use the same exact file in the child theme folder.
the file in question is avia-snippet-hamburger-menu.js
I also found a script that is suppose to deregister the parent file and enqueue the child override..which works buttttttttttttt when i do that…the hamburger menu doesnt close anymore once you open it.
let me know if you need anymore information
October 27, 2021 at 12:01 pm #1326646Hey Jason,
Thank you for the inquiry.
What did you add or modify in the script file? Please provide the site URL and the login details in the private field so that we can check the issue.
Best regards,
IsmaelOctober 27, 2021 at 7:47 pm #1326735So i created a staging environment to show you the difference. I am going to supply the working example which is our live site and the staging site which has it broken. I will denote what is live and what is staging on the private section. The modifications is on line 52 of avia-snippet-hamburger-menu.js and it starts with /**** call second menu *****/ and it ends on line 63. I pasted the code also in the private section.
to briefly explain what is what.
the live site:
i have the modification on the parent file because that is the only way this works. to see what the modification does click on the on hamburger menu and it will be the second menu in the navigation.on the staging site. I have the modified js file in the child theme folder. As you will notice it doesnt work. but if you go to the functions.php i have a function commented out (//Load child theme avia.js) if you remove the comment, the modification does work, but when you go to try to close the hamburger menu..it doesnt retract up. the function starts line 30 and ends on line 37
October 29, 2021 at 11:08 am #1326972Hi,
Thank you for the update.
There is an invalid code in the wp_change_aviajs function. You do not have to define the path of the script when using the wp_dequeue_script and wp_deregister_script functions. All you need is the script handle, which is “avia-hamburger-menu” in this case.
This is the updated script.
// Load child theme avia.js function wp_change_aviajs() { wp_dequeue_script('avia-hamburger-menu' ); wp_deregister_script( 'avia-hamburger-menu'); wp_enqueue_script('avia-hamburger-menu', get_stylesheet_directory_uri().'/avia-snippet-hamburger-menu.js', array('jquery')); } add_action( 'wp_enqueue_scripts', 'wp_change_avia_js', 100 );
Best regards,
IsmaelOctober 29, 2021 at 6:25 pm #1327040i saw that you made the modification to functions, but it doesn’t work. My modification doesn’t appear in the menu like how it does in the live version of the site. It works only if i apply the modification to the parent file but not child file
October 29, 2021 at 6:29 pm #1327041never mind i figured it out… you added an extra underscore to add_acction. it works!!! thank you :D
October 31, 2021 at 12:12 pm #1327184 -
AuthorPosts
- You must be logged in to reply to this topic.