wp_enqueue_script not working
-
Hi All,
I am trying to load a javascript just before the closing body tag. I have created a functions.php file and a javascript file (in a folder called js) in my child theme folder.
The functions.php code is as follows:
<?php
function example_function() {
//Load JS and CSS files in here
wp_register_script ('example_script', get_template_directory_uri() . '/js/example_script.js', array( 'jquery' ),'1', true);wp_enqueue_script('example_script');
}add_action( 'wp_enqueue_scripts', 'example_function' );
?>The code of example_script.js is as follows:
<!-- Quantcast Tag, part 2 -->
<!-- hide script from old browsers
_qevents.push( { qacct:"XXXXXXXXXX"} );
<noscript>
<div style="display: none;">
<img src="https://pixel.quantserve.com/pixel/p-test123.gif" height="1" width="1" alt="Quantcast"/>
</div>
</noscript>
// end hiding script from old browsers -->
From the research I did online, this should be working but, when I check the source code of my homepage, the javascript code is nowhere to be seen.
I would greatly appreciate if someone could review my code and advise me if I have made an error.
Thank you in advance.
Chris
- The topic ‘wp_enqueue_script not working’ is closed to new replies.