I am trying to get scripts via wp_enqueue_script();
. I have tried this in header but WordPress is not importing any script.
I am using like this wp_enqueue_script('jquery');
http://codex.wordpress.org/Function_Reference/wp_enqueue_script
Is any other step needed for importing script via WordPress?
In simple case you need to enqueue script before header scripts are printed, which happens in
wp_head
hook.Basic approach would be this in
functions.php
of your theme:If you have copy/pasted your code, then you have a typo.
Read what the codex says… You should call this inside an action hook… Otherwise it may lead to troubles! Codex suggests you use it with ‘init’ action hook.
^Listen to Otto Sisir!
This is what I usually do for enqueueing custom js on the admin side, ONLY for my plugin’s settings page…
`
By the way, all you can do is use ‘wp_head’ hook and call wp_enqueue_script(‘jquery’) in the function, to use jquery on the frontend (theme) (same way you can include any Javascript library that is inside WP’s js folder). I don’t understand why and what you’re doing by this…
wp_register_script( 'jquery', '/'. WPINC .'/js/jquery/jquery.js');
!