Using wp_enqueue_script to use Jquery
-
I have created a small jquery function which I have placed in a general.js file inside the child theme folder, and have used enque in the functions.php file but I still cant get it to work.
This is inside functions.php
function my_assets() { wp_enqueue_script( 'parent', get_stylesheet_directory_uri() . 'https://www.mysite.co.uk/little-stove-company/wp-content/themes/twentytwenty-child/js/general.js', array( 'jquery' ) ); }Then inside my general.js file I have this
jQuery(document).ready(function( $ ) { $('.post-85.modula-items.img.pic').each( function() { var $img = $(this), href = $img.attr('/newpage'); $img.wrap('<a href="' + href + '" class="link"></a>'); }); });Then when I look in console on the page above I get this issue.
Loading failed for the <script> with source “https://www.mysite.co.uk/little-stove-company/wp-content…wp-content/themes/twentytwenty-child/js/general.js?ver=5.3.2”.Im noty sure what is broken and why its not working.
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Using wp_enqueue_script to use Jquery’ is closed to new replies.