php - WordPress is declaring JQuery in the Footer -
i've been handed wordpress (wp) site 3rd party. work drupal, i'm not well-rounded in wp.
that said, i'm attempting install google tag manager (gtm). however, i'm getting console errors, stating jquery not defined. i've discovered jquery defined in <footer>
, not <head>
. i've had issue in past drupal, i'm not sure begin wp.
after looking @ template, i've discovered there <?php wp_head(); ?>
tag in head , there <?php wp_footer(); ?>
tag in footer. both tags inject scripts, obviously, jquery injected through footer tag. can tell, scripts compiled in script-loader.php document, document little overwhelming. i'm not sure move around in order jquery injected through <?php wp_head(); ?>
tag.
i've uploaded script-loader.php document google drive. i'll put .txt file it's readable within gdrive.
please let me know if there's else can provide. helpful feedback appreciated!
you want register , en-queue scripts in wordpress, don't place them in header/footer yourself.
there functions.php file in theme template folder, inside there may function calling wp_enqueue_scripts hook, search , modify before creating new one.
if not, add this:
add_action( 'wp_enqueue_scripts', 'add_my_script' ); function add_my_script() { wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'jquery-ui-core' ); wp_enqueue_script( 'includes', get_template_directory_uri() . '/js/includes.js?v=2', array( 'jquery', 'jquery-ui-core' ), '1.0', true ); }
but replace third enqueue "includes" gtm include, or delete it. make sure jquery , jquery ui loaded @ correct time. third option makes sure loaded before loading includes.php
Comments
Post a Comment