Opened 16 years ago
Closed 16 years ago
#11944 closed defect (bug) (duplicate)
Allow wp_enqueue_script() after wp_head()
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | General | Keywords: | needs-patch |
| Focuses: | Cc: |
Description
Say you have this code:
function my_template_tag() {
// output some stuff here
wp_enqueue_script('handle', ..., $in_footer = true);
}
It should just work, even if it's called after wp_head().
Currently, you have to do something like this:
function my_template_tag() {
// output some stuff here
add_action('wp_footer', 'my_template_tag_script');
}
function my_template_tag_script() {
wp_register_script('handle', ...);
wp_print_scripts('handle');
}
Change History (4)
Note: See
TracTickets for help on using
tickets.
+1 for this.
Some discussion here, here, and here.