• rhender

    (@rhender)


    hello,

    I am trying to include a javascript only on my contact page. I added the following code to my functions.php file where the other javascript head links are.

    Could anyone tell me if you see something wrong with it? I keep getting errors. “contact-2” is the slug on the contact page.

    The error I’m getting says “unexpected “(” on the first line

    if (is_page('contact-2')) {
    		wp_enqueue_script('contact', get_bloginfo('template_url')."/scripts/contact.js");
    	}
Viewing 1 replies (of 1 total)
  • Thread Starter rhender

    (@rhender)

    The whole block of code for clearer reference…

    // Load jQuery
    function site_add_public_scripts()
    {
    	if (is_home()) {
    		wp_enqueue_script('qt-prototype', "https://www.apple.com/library/quicktime/2.0/scripts/prototype.js", false, '1.0', false);
    		wp_enqueue_script('qtp-poster', "https://www.apple.com/library/quicktime/2.0/scripts/qtp_poster.js", false, '1.0', false);
    		wp_enqueue_style('qtp-poster-css', 'https://www.apple.com/library/quicktime/2.0/stylesheets/qtp_poster.css');
    	} 
    
    	if (is_page('contact-2')) {
    		wp_enqueue_script('contact', get_bloginfo('template_url')."/scripts/contact.js");
    	} 
    
    	if (!is_admin()) {
    		wp_deregister_script('jquery');
    		wp_register_script('jquery', "https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js", false);
    		wp_enqueue_script('jquery');
    	}
    
    	wp_enqueue_script('jquery-cycle', get_bloginfo('template_url')."/scripts/jquery.cycle.all.min.js", array('jquery'), '1.0');
    	wp_enqueue_script('plus-one', "https://apis.google.com/js/plusone.js", array('jquery'), '1.0');
    	wp_enqueue_script('free-quote', get_bloginfo('template_url')."/scripts/free-quote.js");
    }

Viewing 1 replies (of 1 total)
  • The topic ‘including conditional javascript’ is closed to new replies.