WordPress.org

Ready to get started?Download WordPress

Forums

where's the best place to put wp_head? (3 posts)

  1. scormeny
    Member
    Posted 4 years ago #

    I'm working on a website with a number of bells-and-whistles that come from plugins. Of course, plugins often insert a bunch of javascript and css and the like in the page header where wp_head() is located. In most themes I've seen, wp_head comes just before the /head tag, like this

    <?php wp_head() ?>
    
    </head>

    I'm having a problem where I call my stylesheet toward the top of the <head> section, and then a plugin inserts some css or a link to a plug-in specific stylesheet that because of where wp_head() is located, appears later, and so it's very inconvenient for me, it seems, to style those elements in my own stylesheet.

    Therefore, I'm wondering, do you think it matters where wp_head() appears, as long as it is in header.php and between <head></head>? Is there a reason it often seems to be just about </head>?

    Thanks for your thoughts.

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    it's very inconvenient for me, it seems, to style those elements in my own stylesheet

    But that's how CSS is supposed to work. And wp_head() is normally added just before </head> precisely so that plugins can add some basic CSS to any elements that they are adding to a page.

  3. scormeny
    Member
    Posted 4 years ago #

    Thanks, esmi. I get what you're saying, although with some wordpress plugins it is annoying that I can't easily and sensibly overrule their styles to better fit in with my website. For instance, with the Events Manager plugin, the colors in the widgetized sidebar calendar do not work on my website, so I want to override them.

    I've moved wp_head() up to being just below the title attribute, with my css link below that, and so far no other ill effects.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.