Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter vadim-v

    (@vadim-v)

    Perhaps this video is useful to you:
    https://youtu.be/O8ErwPDQcTo?t=2m41s

    The problem is that after the update theme, my code is erased.
    Therefore, I need your plugin. ??

    Plugin Author Joe Rhoney

    (@joerhoney)

    Thanks for the advise! Actually, I’ve been wanted to add that feature since the beginning. It’s a great idea, isn’t it? Unfortunately, it’s much easier said than done. Probably, I need to team up with someone who has mastered regular expressions (which I know little of myself).

    There are a lot of people who want WordPress to have a code tag much like wp_head(), that can be used standardly to add things just after the opening <body> tag, but it doesn’t look like it’s going to be implemented anytime soon.

    So the only practical way to do it currently (that I can think of) is to watch (buffer?) all the code being output by PHP, catch the very tail-end of the <body> tag with a regular expression (regardless of it’s added attributes) and include our code before allowing anymore output to occur. Mainly, I need help with that regular expression.

    Thread Starter vadim-v

    (@vadim-v)

    wordpress – injecting code after the body tag for plugins
    https://maltpress.co.uk/2010/10/wordpress-injecting-code-after-the-body-tag-for-plugins/

    Plugin Author Joe Rhoney

    (@joerhoney)

    Thanks again! While this may serve as a good solution for your needs (and I hope it does), I wouldn’t implement it into my plugin because it uses a javascript approach.

    You might want to try applying the technique in that article to write a script in your functions.php files (if you’re using a child theme).

    Thread Starter vadim-v

    (@vadim-v)

    Ok, thank you!
    If you have any news, please write to this topic!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Need window for code after tag body (for Google Tag Manager)’ is closed to new replies.