I'm still trying to implement the jquery.contenthover.js-Plugin into wordpress, but I just can't make it work.
First, I have unregistered the jQuery loaded by wordpress, because the plugin needs a higher version, and registered & enqueued a higher one.. and then enqueued the plugin-js .. for this I added following to my functions.php
function init_js_scripts() {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery','//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js',false, '2.1.4');
wp_enqueue_script('jquery');
wp_enqueue_script('contenthover', get_template_directory_uri() . '/assets/js/jquery.contenthover.min.js', array('jquery'), false, true);
}
}
add_action( 'init', 'init_js_scripts');
Whatever I try, it won't word :/ .. in the Firefox-Debugger the new jquery is loaded correctly but the jquery.contenthover.min.js is grayed out(?) .. how can I fix that?
EDIT:
Thanks to Jeremy, I now know, that the Plugin-Js is loaded correctly.. but it still won't wirk.. when I extract the code into a new HTML (away from wordpress) it all works fine.. in WP it doesnt.. .. I use
<script type="text/javascript"><!--//--><![CDATA[//><!--
var $j = jQuery.noConflict();
$j(document).ready(function () {
$j('#d1').contenthover({
effect:'slide',
slide_speed:300,
overlay_background:'#000',
overlay_opacity:0.8
});
});
//--><!]]//></script>
but with no effort. Can someone tell me, what I do wrong?
scripttag on your page? It must appear after the other scripts are included. To be sure that it's the case, you should write this script in an external file and enqueue it the same you you enqueued the library (be sure you indicatecontenthoveras a dependency).console.log()for example.