WordPress.org

Support

Support » Plugins and Hacks » Need to filter or hook just after body tag…

Need to filter or hook just after body tag…

  • Is there a way to hook, or filter such that you are able to insert data just after the begin body tag on every page of the blog? Currently I am hooking on wp_footer to get it just before the end body tag. I would really like to move it up the page, as the javascript needs to be there to use the DOM efficiently.

    Thanks,
    – Abyss Knight

Viewing 8 replies - 1 through 8 (of 8 total)
  • Unless you’re trying to design a plugin to work across various themes, why not just add your own function call wherever you want it in your own theme?

    I’d like to make it work for any theme. Basically, I am integrating a web-service into WordPress. It’d be great to just find the body tag and replace it on the fly. I want to make this easy to use, so all users can easily install and use it right out of the box.

    Sounds like you might take advantage of PHP’s output buffering.

    I’ve heard of this, I may need to look into it. I certainly don’t want to conflict with anything WordPress is already doing… Thanks for the idea!

    I would really like to move it up the page, as the javascript needs to be there to use the DOM efficiently.

    I’m really curious why “the javascript needs to be there.”

    Well, its the MyBlogLog script tag. Their site says that for best performance it needs to be right after the begin body tag. You can have the script anywhere on the page, but because of the way it parses links via the DOM it works best at the beginning of the page. 🙂

    With this additional info, in response to your original question, I suggest that you use the “wp_head” hook to put the JavaScript in the header, and modify it so that it runs after the page loads. I’d love to see an explanation for why their support people think JavaScript would work best at the beginning of the page. 🙂

    Anyways, I went ahead and just had it filter the_content and add it to the front as the last filter. Works for me. 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Need to filter or hook just after body tag…’ is closed to new replies.
Skip to toolbar