How can I modify what is being output in wp_head, whether by a theme or WordPress in general?

First: don’t enqueue custom versions of WordPress core-bundled scripts, including (and especially) jQuery.

Second, to answer your question: those Plugin scripts and stylesheets are enqueued, using add_action(), via a callback hooked into one of the following action hooks:

  • wp_head
  • wp_enqueue_scripts
  • wp_print_scripts
  • wp_print_styles

(There are others, but those are the most likely.)

Inside the callback, the following functions are used to enqueue:

So, for a Plugin-enqueued stylesheet, named foobar.css, you’d need to look in the Plugin files for calls to wp_enqueue_style(), then note the name of the callback function it is called within. Then, find the add_action() call that references that callback function. e.g.:

add_action( 'wp_head', 'pluginname_enqueue_styles' );

Once you’ve found that call, you can override it yourself, using remove_action():

remove_action( 'wp_head', 'pluginname_enqueue_styles' );

Leave a Comment