You can load the scripts like this:
function wpa_90150_scripts() {
wp_enqueue_script(
'contenthover',
get_template_directory_uri() . '/js/jquery.contenthover.js',
array('jquery'),
'',
true
);
wp_enqueue_script(
'custom',
get_template_directory_uri() . '/js/custom.js',
array('jquery','contenthover'),
'',
true
);
}
add_action('wp_enqueue_scripts', 'wpa_90150_scripts');
Which I think you’re mostly doing correctly, especially if they are being loaded on your site.
And then initialize the jQuery scripts like this:
jQuery(document).ready(function($) {
$('.d1').contenthover({
effect:'slide',
slide_speed:300,
overlay_background:'#000',
overlay_opacity:0.8
});
});
You don’t know how long I struggled to get my first jQuery script integrated into WordPress! I wanted to break all the things. A lot of jQuery plugin documentation does not work until you do it the WordPress way which is what I posted above… opening with jQuery
and passing the $
variable into the function. Basically, WP’s jQuery is already set to noConflict mode and so you must use the correct wrapper.