1

I have a template that has been hardcoded in the header and it needs to be Enqueued. I don't know what to do and the template provider is giving me the run around. JQueries won't work because of it. I installed the Q&A plugin it won't work properly because of this script. If I delete the script. Q&A works but my menu appearance is gone:

<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/cookie.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/js.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/PIE.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/cusel-min-2.3.1.js"></script>
<script type="text/javascript">
var params = {
        changedEl: "#zip, #zip1, #zip2, #zip3, #zip4, #zip5, #zip6, #zip7, #zip8, #zip9, #zip10, #zip11",
        scrollArrows: true
    }

    cuSel(params);
     $(document).ready(function(){
    jQuery$('div.sel-data').last().css('margin-left','0');
     });
</script>


<!-- superfish menu -->
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/superfish.js"></script>
<script type="text/javascript">
 $(document).ready(function(){
            jQuery('ul.sf-menu').superfish({
                animation:   {opacity:'show', height:'show'},
                speed:       'fast',                          // faster animation speed 
                autoArrows:  false,                           // disable generation of arrow mark-up 
                dropShadows: false                            // disable drop shadows 
            });
 });
  </script>
    <!-- /superfish menu -->
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/cufon-yui.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/Bebas_Neue_400.font.js"></script>

This is what dalton wrote from Q&A.

Your theme is hard-coding a link to the jQuery library in the header. You will need to contact your theme developer and ask them to properly enqueue the scripts instead or your site will have problems with any jQuery based plugins.

I don't know what to do or where to start. Any help would be wonderful

My site is www.halseyschools.com

1
  • js.js :) very original file name... Is this jQuery, because I don't see any reference to it? Jul 20, 2011 at 21:16

1 Answer 1

3

Add your script to a file inside your Theme root, e.g. /js/my-script-name.js.

In functions.php, put add a function to enqueue your script:

function mytheme_enqueue_some_script() {
    if ( ! is_admin() ) {
        $scriptsrc = get_template_directory_uri() . '/js/my-script-name.js';
        wp_register_script( 'my-script-name', $scriptsrc );
        wp_enqueue_script( 'my-script-name' );
    }
}

Then, hook that function into the wp_enqueue_scripts hook:

add_action( 'wp_enqueue_scripts', 'mytheme_enqueue_some_script' );

If your script is dependent on any other scripts, we can add that information to the wp_register_script() call.

For further reading:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.