Support » Fixing WordPress » Removing items from WP_Head Question

  • I’m in the process of cleaning up the wp_head function by adding “remove_action” filters in my functions.php file.

    There are two CSS files being loaded that I would like to remove from the wp_head queue list.

    <link rel='stylesheet' id='admin-bar-css'  href='' type='text/css' media='all' />
    <link rel='stylesheet' id='boxes-css'  href='' type='text/css' media='all' />

    How do I find out what to put in the remove_action() function to pull these out of the header?

    I tried putting the ID in:

    remove_action( 'wp_head', 'admin-bar-css' );
    remove_action( 'wp_head', 'boxes-css' );

    But that doesn’t seem to do the trick. Any help would be appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • esmi


    Forum Moderator

    Why not just disable the admin bar on the front end of your site via your profile page?

    We have multiple admins – some more savvy than others. Its a custom build and there really isn’t any benefit of loading the admin bar – so we figured why load it at all. Lets pull that function out and lower the number of HTTP requests etc.

    add_filter( 'show_admin_bar', '__return_false' );

    These stylesheets became unnecessary when I removed the bar.

    Its actually not just the admin bar CSS files I’m looking to remove, either. There are a few plugins that I have running that I’m trying to figure out similar issues with. I’d love to set up an if-then statement that lets me use remove_action on plugin files when someone isn’t on a page that needs them.

    For example if I only run a certain plugin on the home page, but it loads its’ files on every page, I could do something like this:


    However, I don’t know how to find out what the name of the action is in order to get the remove_action() function to work on it.

    I hope this makes things a little clearer. Thanks for your response!

    This is an older post, but unresolved, so the answer is:

    Search (Ctrl+F) for wp_head and you will find the names.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Removing items from WP_Head Question’ is closed to new replies.