WordPress.org

Ready to get started?Download WordPress

Forums

Need to filter or hook just after body tag... (9 posts)

  1. abyssknight
    Member
    Posted 8 years ago #

    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

  2. Austin Matzko
    Member
    Posted 8 years ago #

    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?

  3. abyssknight
    Member
    Posted 8 years ago #

    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.

  4. Austin Matzko
    Member
    Posted 8 years ago #

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

  5. abyssknight
    Member
    Posted 8 years ago #

    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!

  6. Joshua Sigar
    Member
    Posted 8 years ago #

    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."

  7. abyssknight
    Member
    Posted 8 years ago #

    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. :)

  8. Austin Matzko
    Member
    Posted 8 years ago #

    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. :-)

  9. abyssknight
    Member
    Posted 8 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags