Trouble adding JQuery into custom WordPress theme

Hello all.

I am having some trouble getting jQuery to a custom WordPress theme.

It was working perfect when I called my own version of JQuery but it created issues with plugins. I’ve now used the default JQuery version and tried to enqueue it. My code is:

wp_enqueue_script( ‘effects’, get_template_directory_uri() . ‘/js/effects.js’, array(‘jquery’), ‘’, true );

And trying to include a js which contains:

var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $(‘.main-navigation’).outerHeight();

$(window).scroll(function(event){
	didScroll = true;
});

setInterval(function() {
	if (didScroll) {
		hasScrolled();
		didScroll = false;
	}
}, 250);

function hasScrolled() {
	var st = $(this).scrollTop();
	
	// Make sure they scroll more than delta
	if(Math.abs(lastScrollTop - st) <= delta)
		return;
	
	// If they scrolled down and are past the navbar, add class .nav-up.
	// This is necessary so you never see what is "behind" the navbar.
	if (st > lastScrollTop && st > navbarHeight){
		// Scroll Down
		$('.main-navigation').removeClass('nav-down').addClass('nav-up');
	} else {
		// Scroll Up
		if(st + $(window).height() < $(document).height()) {
			$('.main-navigation').removeClass('nav-up').addClass('nav-down');
		}
	}
	
	lastScrollTop = st;
};

Anyone have any ideas?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.