Archived topic
Jquery installation
9 replies · Started by Daniele on May 13, 2019
Hi, the plugins that need jquery don't work on gp, how can I install jquery on your theme?
Thanks,
Daniele
Hi there,
If a plugin requires jquery, it should load it and not rely on the theme itself.
This should help: https://generatepress.com/forums/topic/theme-conflict-with-wp-simple-paypal-shopping-cart-jquery-checkout-error/#post-888060
Let me know if this helps :)
So I have to add this code to the functions.php file?
add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_script( 'jquery' );
} );
Did I get it right?
Thanks Leo
One of these methods should work.
Adding PHP: https://docs.generatepress.com/article/adding-php/
Is it not quicker to add manually
add_action ('wp_enqueue_scripts', function () {
wp_enqueue_script ('jquery');
});
to the functions.php file?
Thanks
Never a good idea to edit the theme's core files as it will get erased during update.
I have to make changes also to the file footer.php and header.php, to insert banners. In the same way, I could change the functions.php file to insert the jquery function. If the theme is updated, I rarely redo the changes after each update, otherwise, if the updates are frequent, I will have to create a child theme ... what do you say?
Thanks
Our recommendation is always to create a child theme in cases like this but it’s up to you.
OK, I copied this code into the functions.php file
add_action( 'wp_enqueue_scripts', 'tu_load_jquery' );
function tu_load_jquery() {
wp_enqueue_script( 'jquery' );
}
and now everything works!
Thanks Leo!
Daniele
No problem :)