Note that there are some explanatory texts on larger screens.

plurals
  1. POWordpress wp_enqueue_script() NEVER works
    primarykey
    data
    text
    <p>I've read all the posts and the documentation on wp_enqueue script... but I've NEVER successfully gotten it to work.</p> <p>This is what I'm doing that works:</p> <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"&lt;/script&gt; &lt;script type="text/javascript"&gt; MY CODE &lt;/script&gt; </code></pre> <p>I know I know I know this isn't the right way to to do it. So here's what I've tried instead:</p> <pre><code>wp_enqueue_script('jquery'); wp_head(); </code></pre> <p>No luck.</p> <pre><code>add_action('init', 'addscripts'); function addscripts() { wp_enqueue_script('jquery'); } wp_head(); </code></pre> <p>No luck.</p> <pre><code>//in the theme's functions.php file add_action('init', 'addscripts'); //add_action('wp_enqueue_scripts', 'addscripts'); //this also doens't work function addscripts() { wp_enqueue_script('jquery'); } </code></pre> <p>I've also tried the same approaches with the link to the external jquery library at google instead of the <code>jquery</code> tag. I've also tried de-registering and then registering the jquery script. Never works. </p> <p>So I think these are the key questions:</p> <ol> <li><p>Is there something wrong with my call to the <code>wp_enqueue_script()</code> function?</p></li> <li><p>Where should it go? <code>functions.php</code>? <code>header.php</code>?</p></li> <li><p>Is there a specific hook that I need to be using that's not mentioned? <code>'init'</code>? <code>'template_redirect'</code>? <code>'wp_enqueue_scripts?'</code>?</p></li> </ol> <p>Please, no copy/pasted snippets from the <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" rel="nofollow">codex</a>! I've read it 50 times and tried them all. I promise.</p> <p>I'm experimenting with a clean installation of WP3 and adding the above code to the default twentyeleven theme.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload