Trouble Enqueueing Script

Community Forums Forums General Discussion Trouble Enqueueing Script

This topic is: resolved

This topic contains 1 reply, has 2 voices, and was last updated by  David Chu 1 year ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #55849

    electricbrick
    Participant
    Post count: 62

    I’m using the following snippet in functions.php to call a JS file:

    /** iOS Orientation Fix */
    add_action('genesis_footer', 'genesis_ios_fix');
    function genesis_ios_fix() {
            wp_register_script( 'iosfix',  CHILD_DIR . '/lib/ios-fix/ios-orientationchange-fix.js' );
            wp_enqueue_script ( 'iosfix');
    }

    Upon upgrading to Genesis 2.0, the path shown in the rendered HTML now looks like this:

    src=’http://www.myclient.com/mnt/stor1-wc1-dfw1/390554/841675/www.myclient.com/web/content/wp-content/themes/clienttheme/lib/ios-fix/ios-orientationchange-fix.js’

    It appears that WordPress and/or Genesis is detecting the absolute path on my server as well as the child theme directory. Did something change in 2.0 that requires me to enqueue scripts differently? I’ve tried modifying the call using get_stylesheet_directory_uri() instead of CHILD_DIR, and the path is still incorrect (identical to the path shown above).

    Note: I cannot provide a link to the site as it is protected per an NDA.

    #56200

    David Chu
    Participant
    Post count: 1346

    Hi,
    I’m psychic, so I can see your site anyway. That’s a funny NDA. :-)

    Anyway, I think what you want there is “CHILD_URL” rather that DIR. DIR gives you the great big path, and AFAIK it has done that since early Genesis, so I’m intrigued that it would have worked before.

    Cheers, Dave


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.