开发者

Wordpress Child Theme & enqueue_script

开发者 https://www.devze.com 2023-03-21 23:30 出处:网络
I\'m trying to enqueue a script directly from my child theme\'s header just after the wp_hook, but for the life of me it\'s not showing up - what gives?

I'm trying to enqueue a script directly from my child theme's header just after the wp_hook, but for the life of me it's not showing up - what gives?

// register your script location, dependencies and version
   wp_register_script('jqtransform',
   get_bloginfo('stylesheet_directory') . '/includes/jq开发者_开发问答transformplugin/jquery.jqtransform.js', false);
// enqueue the script
   wp_enqueue_script('jqtransform');

Here's the link.


Turns out I needed to add enqueue_script BEFORE the wp_head call, as well as use a different URL path thingamabob. Here's the final code:

function add_my_scripts(){
    wp_register_script('jqtransform', 
    get_bloginfo('stylesheet_directory').'/includes/jqtransform/jquery.jqtransform.js', array('jquery'),'1.0');
    wp_enqueue_script('jqtransform'); 
}
add_action('init', 'add_my_scripts');
0

精彩评论

暂无评论...
验证码 换一张
取 消