• Resolved Jajton

    (@jajton)


    i want to embed the jquery glossary on my wordpress page..
    This is my code in my function.php

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    <?php
    function my_init() {
    	if (!is_admin()) {
    
    	wp_deregister_script('jquery');
    	wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js");
    	wp_enqueue_script('jquery');
    
    	wp_deregister_script('scroll');
    	wp_register_script('scroll', get_option("siteurl") . '/wp-content/themes/twentyeleven/js/scroll.js');
    	wp_enqueue_script('scroll');
    
    	wp_deregister_script('scrollTo');
    	wp_register_script('scrollTo', get_option("siteurl") . '/wp-content/themes/twentyeleven/js/jquery.scrollTo-min.js');
    	wp_enqueue_script('scrollTo');
    
    	}
    }
    add_action('init', 'my_init');
    ?>

    i can see the jquery on the view source page but it wont execute. Pls help?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Can we have a link to the page to investigate?

    Thread Starter Jajton

    (@jajton)

    Hi Andrew.. im just using localhost.. this is the Jquery that i used https://www.packtpub.com/article/simple-alphabetical-glossary-using-jquery

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Try a slight (untested) modification, I think it may be the add_action()

    <?php
    function my_jquery() {
    	wp_deregister_script('jquery');
    	wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js");
    	wp_enqueue_script('jquery');
    
    	wp_deregister_script('scroll');
    	wp_register_script('scroll', get_option("siteurl") . '/wp-content/themes/twentyeleven/js/scroll.js');
    	wp_enqueue_script('scroll');
    
    	wp_deregister_script('scrollTo');
    	wp_register_script('scrollTo', get_option("siteurl") . '/wp-content/themes/twentyeleven/js/jquery.scrollTo-min.js');
    	wp_enqueue_script('scrollTo');
    }
    
    if (!is_admin()) {
    	add_action( 'wp_enqueue_scripts' , 'my_jquery' );
    }
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Jquery on page’ is closed to new replies.