WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Adding your own JS without breaking WP Plugin JS Scripts (3 posts)

  1. theejonnyb
    Member
    Posted 3 years ago #

    Hey guys I'm having trouble with loading my js scripts properly. Reading the codex I'm a bit confused as to how to properly load them in my header. With out them my menu does not work nor image swaps. Some of the effects and rely on the google library for JQuery, but the rest are in a folder stored in my themes folder.

    How do you call them properly to load in the header without removing the wp_head() which is what the widgets and plugins rely on.

    My scripts work perfect but only when I remove the wp_head() info. But then I know that sets me up for less compatible widget control and the beauty of WordPress.

    Here is what I deleted for my scripts to work.

    /* We add some JavaScript to pages with the comment form
    * to support sites with threaded comments (when in use).
    */
    
    /*if ( is_singular() && get_option( 'thread_comments' ) )
    wp_enqueue_script( 'comment-reply' );*/
    
    /* Always have wp_head() just before the closing </head>
    * tag of your theme, or you will break many plugins, which
    * generally use this hook to add elements to <head> such
    * as styles, scripts, and meta tags.
    */
    
    /* wp_head(); */

    Here is scripts I loaded in the head. I know that some might interfere. I know that there is a certain way to load them but am confused as to how to do that properly.

    <!--[if lte IE 6]>
    	<script type="text/javascript" src="http://new.saa.edu/wp-content/themes/saa/js/supersleight/supersleight-min.js"></script>
    <![endif]-->
    
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
    <script type="text/javascript" src="http://new.saa.edu/wp-content/themes/saa/js/swapimage/jquery-1.2.6.min.js"></script>
    <script type="text/javascript" src="http://new.saa.edu/wp-content/themes/saa/js/swapimage/jquery.metadata.min.js"></script>
    <script type="text/javascript" src="http://new.saa.edu/wp-content/themes/saa/js/swapimage/jquery.swapimage.min.js"></script>
    
    <script type="text/javascript" src="http://new.saa.edu/wp-content/themes/saa/js/jquery.hoverIntent.minified.js"></script>
    
    <script type="text/javascript" src="http://new.saa.edu/wp-content/themes/saa/js/swfobject.js"></script>

    Thank You in advance, the lessons are much appreciated!
    Jonny B'

  2. davesnothere
    Member
    Posted 3 years ago #

    Did you ever get this to work? I'm having a similar problem.

  3. davesnothere
    Member
    Posted 3 years ago #

    Thanks to the post by demetris on this thread: http://wordpress.org/support/topic/wp_enqueue_script-ver-keeps-showing-up I was able to solve this. YMMV

    I used the following

    wp_enqueue_script("metadata", "/wp-includes/js/jquery/jquery.metadata.min.js", false, null);
    	wp_enqueue_script("swap", "/wp-includes/js/jquery/jquery.swapimage.min.js", false, null);

    AND I had to also substitute jQuery for the $

    <script type="text/javascript">
    	jQuery.swapImage(".swapImage");
    </script>

    Now all works properly. :)

Topic Closed

This topic has been closed to new replies.

About this Topic