Warning: include(/home/185104/domains/s185104.gridserver.com/html/wp-content/plugins/wp-synhighlight/object.php) [function.include]: failed to open stream: No such file or directory in /nfs/c06/h05/mnt/185104/domains/tommaitland.net/html/wp-config.php on line 42

Warning: include() [function.include]: Failed opening '/home/185104/domains/s185104.gridserver.com/html/wp-content/plugins/wp-synhighlight/object.php' for inclusion (include_path='.:/usr/local/php-5.3.29/share/pear') in /nfs/c06/h05/mnt/185104/domains/tommaitland.net/html/wp-config.php on line 42
Disabling jQuery No Conflict Mode in Wordpress - Tom Maitland

Tom Maitland

Creates digital things at Agency. WordPress developer. Web designer. Communicates for UN Youth Australia.

Disabling jQuery No Conflict Mode in WordPress

20 October 2012

The bundled WordPress jQuery ships in noConflict() mode (only supporting the jQuery variable), meaning any jQuery that uses $ doesn’t run. Although wrapping it in a function that passes the variable as an alias works, it doesn’t work for scripts you include from elsewhere that might use the $. Plus it’s a massive headache. If you’re sure you’re not using any other libraries that would conflict, here’s how you bring $ back.

Straight after <?php wp_head(); ?> in header.php enter:

[codesyntax lang=”javascript”]

<script>var $ = jQuery.noConflict();</script>


Now just make sure your other scripts are included below that line. If you’re using wp_enqueue_script, you could also include this code in a separate file and set is a dependency for your other scripts.