Support » Fixing WordPress » Conditional Statements not working in functions.php

  • Resolved AngelEyes

    (@clustervision)


    I know that there are some things that you can do in your templates that effect the use of conditional statements. I have this function that loads my scripts in functions.php. These conditional statements have no effect. If I take the wp_register_script and enqueue out of the conditional statement it works fine. Its the conditional that is broken.

    Is there anything that I’m not noticing here? Is there something that is well documented as causing conditional statements to break that I should look for?

    /**
     *	Enqueue Scripts
     */
    
    if ( !function_exists('ScriptLoader') ) {
        function ScriptLoader() {
        	if (!is_admin()) {
    
    		wp_deregister_script( 'jquery' );
    		wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js', array(), '1.6.4', false );
    		wp_enqueue_script( 'jquery' );
    
    		if ( is_home() || is_archive() ) {
    
    			wp_register_script( 'easyslider', 'http://www.myurl.com/wp-content/etc/js/libs/easySlider1.5.js', array( 'jquery' ), '1.5', true );
    
    			wp_enqueue_script( 'easyslider' );
    
    			}
    		if ( is_page(77) ) {
    
    			wp_register_script( 'mail', 'http://www.myurl.com/wp-content/etc/js/mail.js', array( 'jquery' ), '1.0', true );
    
    			wp_enqueue_script( 'mailchimp' );
    
    			}
    
    		}
    
        }
    
    }
    add_action('init', 'ScriptLoader');
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Conditional Statements not working in functions.php’ is closed to new replies.