Support » Plugins » Add an include after <body> with a plugin

  • Bruz

    (@bruz)


    Hi!

    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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Kwebble

    (@kwebble)

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

    Bruz

    (@bruz)

    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.

    Kwebble

    (@kwebble)

    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:

    do_action('body_start');

    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?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add an include after <body> with a plugin’ is closed to new replies.