• Hi background images on this site are created by a jquery script another developer created that makes the background from the page’s featured image. It recently stopped working. My skills in this area aren’t very extensive but i do see the above error in the chrome browser console as well as

    Uncaught TypeError: jQuery is not a function

    Could someone give me some guidance as to how to sort this out.

    Much appreciated

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • The message comes because the jQuery library is not integrated or is integrated too late. Your developer’s custom script is probably loaded too early. Since you seem to be using a custom theme, it’s hard to find a solution. My advice would be to contact your developer. Alternatively, you would have to check and adjust the programming yourself.

    Thread Starter stevebrett

    (@stevebrett)

    Thanks its just a 2021 child theme and the script is loaded in home.php I think

    Unfortunately the prior developer is no loner in the picture so im trying so sort this out for them.

    Any other guidance would certainly be appreciated

    Then the implementation must be adapted accordingly. There is no click&play solution for this. Since you do not show the programming here, it is hardly possible to give you further guidance.

    Thread Starter stevebrett

    (@stevebrett)

    Thanks so this same error appears for three scripts on the home page and in others through out the site. Heres one such. If you could give me any guidance at all it would be appreciated for sure

    jQuery(function($){
    
    	var width=$( window ).width();
    
    	if (width < 501) {  
    		$('.scrollright').click(function() {
    		    $('#videos-home').animate( { scrollLeft: '+=350' }, 1000);
    		});
    		$('.scrollleft').click(function() {
    		    $('#videos-home').animate( { scrollLeft: '-=350' }, 1000);
    		});
    	}
    	if ((width > 500) && (width < 768)) {  
    		$('.scrollright').click(function() {
    		    $('#videos-home').animate( { scrollLeft: '+=525' }, 1000);
    		});
    		$('.scrollleft').click(function() {
    		    $('#videos-home').animate( { scrollLeft: '-=525' }, 1000);
    		});
    	} 
    	if (width >767) {  
    		$('.scrollright').click(function() {
    		    $('#videos-home').animate( { scrollLeft: '+=705' }, 1000);
    		});
    		$('.scrollleft').click(function() {
    		    $('#videos-home').animate( { scrollLeft: '-=705' }, 1000);
    		});
    	}
    
    });
    
    </script>
    

    This is the code that is executed in the output in the browser. My question was about the PHP code from the supposed home.php (even if the file name is unusual for WordPress). Or to put it another way, it’s about how the JavaScript code you showed is integrated into WordPress. If you can’t find that, I would recommend you to look for a developer who can support you.

    Hey @stevebrett,

    If you view your network console and the <head></head> area of your source for your home and about page, you’ll definitely see that jQuery isn’t loaded for those pages.

    I see jQuery loaded on your other pages.

    Just a guess but, jQuery might be getting selectively removed for your home and about pages. There could be some custom code in your child theme’s functions.php or in your Simple Custom CSS and JS plugin that’s dequeuing and deregistering jquery for those 2 pages.

    That code could look something like this.

    
    function remove_my_jquery() {
    	if ( ! is_admin()) {
                    if ( is_page( array( 'home', 'about' ) ) ) {
    			wp_dequeue_script( 'jquery' );
    			wp_deregister_script( 'jquery' );
    		}
    	}
    }
    add_action( 'wp_enqueue_scripts', 'remove_my_jquery' );

    `

    I would really ask your developer to save time hunting for code.

    Good luck!

    Thread Starter stevebrett

    (@stevebrett)

    Hi and thanks i looked to see if jquery was being deregistired anyplace and don’t see that it is.

    However following a suggestion in another thread I added the jquery migrate helper plugin. With that installed the functionality is restored- However only if i’m logged in.

    Does that provide any useful clues to help us along here?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘jQuery is not defined’ is closed to new replies.