Forums

How to convert script tags to wp_enqueue_script (that work) -- please help (2 posts)

  1. vntttt
    Member
    Posted 11 months ago #

    Hi guys,

    Thanks for your time in reading this!

    Currently, I am creating a page to fundraise for cancer research and would greatly appreciate your expert advice on implementing the below HTML code into my WordPress theme. My problem is that the CSS renders fine, however, the scripts don't seem to work no matter what I try.

    Original HTML:
    http://pastebin.com/Ca3dyXd9

    *DEMO*:
    http://fredpham500.org.au/backup

    I tried adding this to footer.php before wp_footer() at one stage:

    <?php
    	wp_register_script('hoverintent_js', get_bloginfo( 'template_url' ) . '/js/jquery.hoverIntent.js', array('jquery'));
    	wp_enqueue_script('hoverintent_js');
    	wp_enqueue_script('scripts_js', get_bloginfo( 'template_url' ) . '/js/scripts.js', array('hoverintent_js'), '1.0', true);
    ?>

    this to functions.php at another:

    function init_hoverintent() {
    if ( !is_admin() ) {
    			wp_register_script('hoverintent_js', get_bloginfo('template_url') . '/js/jquery.hoverintent.js', array('jquery'));
    			wp_enqueue_script('hoverintent_js');
    			wp_enqueue_script('scripts_js', get_bloginfo('template_url') . '/js/scripts.js', array('hoverintent_js'), "1.0", true);
    		}
    }
    add_action('template_redirect', 'init_hoverintent');

    and even this to footer.php before wp_footer() in a final attempt:

    <script type="text/javascript" src="http://www.fredpham500.org.au/wp-content/themes/sabuy/js/jquery.hoverIntent.js"></script>
    <script type="text/javascript" src="http://www.fredpham500.org.au/wp-content/themes/sabuy/js/scripts.js"></script>

    ...however, all without any success.

    Can someone please advise me what I am doing wrong and how I might be able to resolve this? I am certain I am close, just not quite there.

    Thank you kindly for your assistance.

    Many thanks,
    Tam

    PS. You can download Brian Cherne's fantastic jquery.hoverintent.js at this link: http://cherne.net/brian/resources/jquery.hoverIntent.html

  2. vntttt
    Member
    Posted 11 months ago #

    Hello there,

    Just in case it would help you with trouble-shooting, here is the CSS:
    http://pastebin.com/EXDHR56C

    Many thanks,
    Tam

Reply

You must log in to post.

About this Topic