[wp-hackers] How to enqueue default scrips in footer?
Andrew Ozz
admin at laptoptips.ca
Sat Sep 26 20:17:16 UTC 2009
Milan Dinić wrote:
> Thank you for your answers. Tynan's approach still places it in header while
> Otto's make error (Call to a member function add_data() on a non-object in
> ...).
There are actions to specifically enqueue scripts and stylesheets:
http://core.trac.wordpress.org/browser/trunk/wp-includes/script-loader.php#L684
http://core.trac.wordpress.org/browser/trunk/wp-admin/admin-header.php#L54
If you really need to change the location of a default script by hand
you could use:
$wp_scripts->add_data('handle', 'group', 1 );
as Otto suggested, where 1 = footer, 0 = head. This has to run after the
scripts are added/registered but before any scripts are printed, best
done from the above actions with priority of 11 or more.
However note that scripts are moved from the footer to the head if a
dependent script is enqueued there, forcing the default script back to
the footer would break the dependency.
More information about the wp-hackers
mailing list