Grow your CSS skills. Land your dream job.

WordPress wp_head call bringing in loads of crap

  • # May 22, 2013 at 1:18 pm

    Just building a WP theme and I trying to create everything from scratch so I can create my own framework and also to keep things as clean as possible.

    I’ve noticed that as soon as I add the wp_head call WordPress adds a few lines of crap. It looks like most of it is for the admin bar but its inserted css into the head using the old text/css.

    Just wondered if I can stop or change this css?

    I know I can turn off the admin bar is this the only way?

    # May 22, 2013 at 1:38 pm

    Put this in your functions.php file

    // clean head
    remove_action(‘wp_head’, ‘rsd_link’);
    remove_action(‘wp_head’, ‘wlwmanifest_link’);
    remove_action(‘wp_head’, ‘index_rel_link’);
    remove_action(‘wp_head’, ‘parent_post_rel_link’, 10, 0);
    remove_action(‘wp_head’, ‘start_post_rel_link’, 10, 0);
    remove_action(‘wp_head’, ‘adjacent_posts_rel_link_wp_head’, 10, 0);
    remove_action(‘wp_head’, ‘wp_generator’);
    // remove admin bar
    add_filter(‘show_admin_bar’, ‘__return_false’);

    # May 22, 2013 at 1:56 pm

    The [Bones](http://themble.com/bones/ “Bones”) starter theme has a nice wp_head cleanup function I usually port over when I’m not using it as a base.

    # May 22, 2013 at 5:38 pm

    Thanks, didn’t know about this.

    By the way when I added the footer call even more was added, is there a clean up for the footer too?

    Don’t mind the admin bar but I can’t cope with this amount of junk.

    One other thing, is there a way to stop WP using absolute paths to assets?

    # May 23, 2013 at 2:31 am

    Check out [Roots](https://github.com/retlehs/roots/), in particular the various cleanup and stuff in /lib/. There’s some very useful things to mine there, even if you don’t want to use all of it.

    # May 23, 2013 at 2:35 am

    interessting, will use it for my new theme too.

    # May 23, 2013 at 5:23 am

    Thanks Melindrea once again!

    # May 23, 2013 at 5:25 am

    I’ve been a bit of a numpty here, when I was seeing most of that junk I was logged in. Now I’ve logged out a lot of it has disappeared so most of it was the admin bar.

    Thanks again for the links though!

    # May 23, 2013 at 8:39 am

    In the past you had to edit WordPress core files to customize something. Now for most things there are [Hooks, Actions and Filters](http://codex.wordpress.org/Plugin_API). [WordPress Hooks Database](http://adambrown.info/p/wp_hooks) is another great resource to have handy.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".