Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to add a simple jQuery script to WordPress?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 421
    Comment on it

    Hello readers, today we discuss about "How to add a simple jQuery script to WordPress?".

    There are two way to add script in our wordpress.

    In header.php file, and in function.php file

    In header.php file you can put the below line into head section.

    <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/jquery.min.js"></script>
    

    or

    <script type="text/javascript" src="<?php bloginfo('template_url');?>/js/jquery.min.js"</script>
    

    In function.php file you can put the below code into it.

    <?php
    add_action( 'wp_print_scripts', 'themeName_scripts' );
    
    
    function theme_scripts()
    {
        if ( !is_admin() ) :
    
      wp_enqueue_script( 'theme-jquery-min', 'http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js' );
    
    endif; 
    
    }
    ?>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: