Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Talk:Function Reference/wp enqueue script

$ver defaults to WP version

The $ver parameter is supposed to default to "false", but, instead, it seems to be defaulting to the WordPress version.

EXAMPLES: While enqueueing these examples, no "$ver" was passed, and the RESULTs are what is created in the <head> section of the page:

1. wp_enqueue_script( 'jquery-cycle', get_bloginfo( 'template_directory' ) . '/js/jquery.cycle.all.js', array( 'jquery' ) );

  RESULT - jQuery gets the proper version:
  <script type='text/javascript' src='http://example.com/wordpress/wp-includes/js/jquery/jquery.js?ver=1.4.2'></script>
  RESULT - The jquery-cycle script receives ver. 3.0.3, when the actual version is 2.88:
  <script type='text/javascript' src='http://example.com/wordpress/wp-content/themes/theme-name/js/jquery.cycle.all.js?ver=3.0.3'></script>


2. wp_enqueue_script( 'script-name', get_bloginfo( 'template_directory' ) . '/js/script-name.js', array( 'jquery-cycle' ) );

  RESULT - This script receives ver. 3.0.3, when it has no version number at all:
  <script type='text/javascript' src='http://example.com/wordpress/wp-content/themes/theme-name/js/script-name.js?ver=3.0.3'></script>

Cydward 18:44, 22 December 2010 (UTC)


Hi Cyward, you are correct. The WP version is used as a default when no version is supplied. It looks like the description of the parameter has already been updated to reflect this.
Jdgrimes 15:57, 7 March 2014 (UTC)