I know that this issue is common and there are many similar questions about it but still my problem is a little different I have an issue regarding the last update of WordPress. The side menu and search bar do not work except in customize mode where the browser loads the migration jquery version 3. I tried all the different solutions (loading manually jquery - WordPress plugin - edit on the theme code - add some function to load jquery with hooks and without hooks) but nothing worked. I will be grateful to hear any suggestions. Note: slide menu and search bar are parts of the Theme (not a plugin). Thank you in advance
I know that this issue is common and there are many similar questions about it but still my problem is a little different I have an issue regarding the last update of WordPress. The side menu and search bar do not work except in customize mode where the browser loads the migration jquery version 3. I tried all the different solutions (loading manually jquery - WordPress plugin - edit on the theme code - add some function to load jquery with hooks and without hooks) but nothing worked. I will be grateful to hear any suggestions. Note: slide menu and search bar are parts of the Theme (not a plugin). Thank you in advance
Share Improve this question edited Jan 19, 2021 at 1:38 Abdulrazzak asked Jan 19, 2021 at 1:21 AbdulrazzakAbdulrazzak 11 bronze badge 4- If you're on WordPress 5.6 try testing with this plugin: wordpress/plugins/enable-jquery-migrate-helper It'd help if you provided the console errors you're seeing and the jQuery code that causes them. – Tony Djukic Commented Jan 19, 2021 at 3:04
- Thank you very much for the comment but unfortunately, I already tried it and it did not work, the plugin does not report anything (blank logged description) - I do not know why everything works only in customize mode – Abdulrazzak Commented Jan 19, 2021 at 11:47
- 2 you should not dequeue jQuery! Aside from compatibility issues, this doesn't actually improve performance. People did this on the assumption that if one site caches it, the next site won't have to fetch it, but browsers have included the domain in the cache key for a decade now, so you don't gain any benefit, you just get lots of cached copies of the same resource. I strongly advise against this – Tom J Nowell ♦ Commented Jan 19, 2021 at 16:36
- Also, the code in the screenshot pins you to version 3.5.1 of jQuery, instead of using the version bundled with WordPress, which will change over time. – Pat J Commented Jan 19, 2021 at 17:16
1 Answer
Reset to default 0I had a similar problem after updating WordPress, try adding this in functions.php :
function load_jquery()
{
wp_register_script('mainJquery', get_template_directory_uri() . '/assets/js/jQuery.js', array('jquery'), 1, true);
wp_enqueue_script('mainJquery');
}
add_action('wp_enqueue_scripts', 'load_jquery');
I was only missing array('jquery'), maybe it's the same for you...