Notice: These forums are now retired and closed. For active support, please Submit a Ticket or visit our official WordPress.org community pages.
Kadence Theme | Kadence Blocks | Starter Templates | WooCommerce Email Designer | Ascend | Virtue | Pinnacle

Scripts

Home / Forums / Virtue Theme / Scripts

This topic is: Resolved
[Resolved]
Posted in: Virtue Theme
February 26, 2015 at 5:18 pm

Hi,

Lets Say I want to add my own jQuery script called “jquery_test.js” located in my child theme.

Inside the script I have:

(function($) {
$(document).ready(function(){

if(window.location.href == ‘ {
setInterval(function() {
$(‘img’).effect(‘bounce’,10)
}, 50);
}
})(jQuery);

Now how do I load this script on my web page? Do I add this to my functions.php in my child theme?

function add_my_script() {
wp_enqueue_script(
‘custom-script’, // name your script so that you can attach other scripts and de-register, etc.
get_stylesheet_directory_uri() . ‘/custom_js/jquery_test.js’, // this is the location of your script file
array(‘jquery’) // this array lists the scripts upon which your script depends
);
}
add_action( ‘wp_enqueue_scripts’, ‘add_my_script’ );

Thanks,
Emre

  • The forum ‘Virtue Theme’ is closed to new topics and replies.