Home > Back-end >  Installed fresh wordpress 5.8 but why Jquery library don't show on frontend of twenty twentyone
Installed fresh wordpress 5.8 but why Jquery library don't show on frontend of twenty twentyone

Time:09-25

Installed Fresh wordpress version 5.8 Theme active - Twenty Twentyone

Problem - Jquery library doesn't load on front-end.

Tried to run few Jquery commands in header.php but error generates in Inspect element tool saying "Jquery is not defined". I understand by default wordpress comes bundled with Jquery which is included in wp-includes directory.

CodePudding user response:

Typo? Jquery() vs. jQuery().

Otherwise, try viewing source and clicking through to the linked jQuery file. The WP hosting environment could play a part here in whether the file is linking correctly.

CodePudding user response:

I fixed it myself.

The Problem was related to wordpress Twenty Twentyone theme. Wordpress actually comes bundled with Jquery but the new Twenty Twentyone theme doesn't include code to enable/register Jquery. I placed a code in functions.php to register Jquery with this theme and now the Jquery is loading on frontend.

Here is I used in functions.php

function load_scripts(){
    wp_enqueue_script('jquery'); # Loading the WordPress bundled jQuery version.
    //may add more scripts to load like jquery-ui
}
add_action('wp_enqueue_scripts', 'load_scripts');

The Previous wordpress theme like Twenty Sixteen , Twenty Thirteen always had this code implemented in functions.php file so we always got Jquery library loading at front-end.

  • Related