I am using an Woo theme. In the parent theme, there is this function:

function woothemes_wp_head() {
  do_action( 'woothemes_wp_head_before' );
  if ( function_exists( 'woo_output_alt_stylesheet' ) )
  if ( function_exists( 'woo_output_custom_favicon' ) )
  if ( function_exists( 'woo_head_css' ) )
  if ( function_exists( 'woo_shortcode_stylesheet' ) )
  if ( function_exists( 'woo_output_custom_css' ) )
  do_action( 'woothemes_wp_head_after' );
add_action( 'wp_head', 'woothemes_wp_head', 10 );

The above function basically adds different stylesheets inside <head>.

I am wanting to move the stylesheets up in the html markup. In my child theme's functions.php, this is what I tried:

remove_action( 'wp_head', 'woothemes_wp_head', 10 );
add_action( 'wp_head', 'woothemes_wp_head', 2 );


remove_action( 'wp_head', 'woothemes_wp_head');
add_action( 'wp_head', 'woothemes_wp_head', 2 );

Both these codes place the stylesheets up in the <head> but also retains the original ones; ie it makes 2 copies. remove_action doesn't seem to get rid of the original stylesheets.

I tried this code:

add_action('wp_head', 'woothemes_wp_head', 2);
function woothemes_wp_head() {
    remove_action( 'wp_head', 'woothemes_wp_head', 10 );

This one completely removes the stylesheets.

So how do I simply change the priority?


Your child theme functions.php loads before the parent theme's, so you're trying to remove the action before it's added by the parent theme.

Hook after_setup_theme to remove/add, which is executed after both child and parent load.

add_action( 'after_setup_theme', 'wpd_wp_head_function' );
function wpd_wp_head_function() {
    remove_action( 'wp_head', 'woothemes_wp_head', 10 );
    add_action( 'wp_head', 'woothemes_wp_head', 2 );
  • Yes, I realise why this was happening as you've explained. I tried your code but that's still adding duplicate stylesheets in html. So is there no other way to fix this behaviour from the child theme? – user1448031 Apr 10 '16 at 5:41
  • if there's duplicate, then again, you're not actually removing it, so there is something wrong in your code. edit your question to show exactly what you've got in your child theme now. – Milo Apr 10 '16 at 6:24
  • maybe another hook from main theme, like this github.com/rememberlenny/WooThemes-Canvas-Foundation-Zombie/… sometime OP not include all in context. – Jevuska Apr 10 '16 at 7:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.