Add an include after <body> with a plugin (4 posts)

  1. Bruz
    Posted 8 years ago #


    I'd like to include a top-menu in several WP-Blogs and therefore it is necessary to include a single php-file just after the <body>-tag and a css-file in the header.

    I think this is easy for someone familiar with the hooks, but I'm not...

    So thanks for your help!

  2. Kwebble
    Posted 8 years ago #

    Why do you want to use hooks? Can't you change your templates and put the needed include statements where you want them?

  3. Bruz
    Posted 8 years ago #

    I could - but I want to use it in 13 blogs with different themes and it should be possible to change the themes or even use a new one and still have the menu on the very top.

  4. Kwebble
    Posted 8 years ago #

    Creating the plugin is not that difficult and by using the hook wp_head the CSS can be added to the <head>.

    The problem is that there is no default hook defined for the beginning of the <body>. And because it is not defined, themes don't include a call to execute plugins at that point.

    That means that for a plugin to add HTML right after <body> you must also change the templates of each theme to include a call to something like:


    Here body_start is the name of a new hook you define.

    So it can be done with a plugin, but not without changing template files. And that's just what you didn't want.

    Perhaps someone else with a solution?

Topic Closed

This topic has been closed to new replies.

About this Topic