How do I add a simple jQuery script to WordPress?

后端 未结 18 1732
心在旅途
心在旅途 2020-11-22 16:53

I read the Codex and a few blog posts about using jQuery in WordPress, and its very frustrating. I\'ve got as far as loading jQuery in functions.php file, but a

18条回答
  •  花落未央
    2020-11-22 17:38

    you can write your script in another file.And enqueue your file like this suppose your script name is image-ticker.js.

    wp_enqueue_script( 'image-ticker-1', plugins_url('/js/image-ticker.js', __FILE__), array('jquery', 'image-ticker'), '1.0.0', true ); 
    

    in the place of /js/image-ticker.js you should put your js file path.

提交回复
热议问题