3

I'm trying to customize a theme, and I see that the header.php calls "wp_head()". I can't seem to find an implementation of this in the theme, so I presume there is a default implementation that implements, for example, the Color Options settings as specified on the admin page.

So my related questions are:

  • Is there somewhere I can see this default implementation?
  • Can this default implementation be "turned off"?
  • Can the "Color Options" option be disabled in the admin screen for the theme?

Please feel free to point me to relevant documentation if that would be easier. I've looked at the reference pages for the wp_head() function and the corresponding wp_head action hook, but they don't seem to provide enough information for me to tackle the questions above.

Thanks.

1 Answer 1

4

Is there somewhere I can see this default implementation?

wp_head() function simply triggers the wp_head action hook that runs all callback functions that were added to this hook using add_action('wp_head','callback_function'); So there is no default implementation.

Can this default implementation be "turned off"?

Like we said before since there is no default implementation you need to find the add_action's that hook to wp_head and remove them using remove_action for example if this is the add_action:

add_action('wp_head','callback_function');

then to remove it just add

remove_action('wp_head','callback_function');

Can the "Color Options" option be disabled in the admin screen for the theme?

I'm assuming that your theme as some kind of options panel that let you chose the color options, so to disable it it depends on the theme it self but it should be in one of the theme files, knowing what theme you are talking about would help.

Update

there are some action by defult running when wp_head is fired and to remove them just use:

remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);

other then that look for add_action('wp_head' ... in theme files and plugins.

4
  • thanks for the responses. I'm playing with the Twenty Ten theme, which was included with the WordPress I downloaded. If I grep for "wp_head", there is only one occurrence - the call in header.php. I can't find any "add_action('wp_head')". However, something seems to be called by wp_head(), since my final HTML includes a number of tags where wp_head() was, including a CSS style for body (implementing my colour choice in the admin screen). So I suppose my question is, where is the code for doing this, and can I bypass it? Thanks.
    – user4184
    Commented Mar 24, 2011 at 12:50
  • @ephemeral: i updated my answer
    – Bainternet
    Commented Mar 24, 2011 at 13:04
  • @ephemeral: glad to help.
    – Bainternet
    Commented Mar 24, 2011 at 13:16
  • Beautiful. Exactly what I needed. I was able to modify <link ref="canonical" ... tag that WordPress automatically outputs with wp_head() call by removing the default function for outputting it like so: remove_action('wp_head','rel_canonical');. Then I registered my own like so: add_action('wp_head', 'my_custom_rel_canonical'); and I added all this code in the header.php template because I need to do it there instead of the usual functions.php template. So now I know that works quite well. Thanks Bainternet.
    – racl101
    Commented Feb 21, 2014 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.