Skip to content

Instantly share code, notes, and snippets.

@eddt
Created May 10, 2016 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eddt/398124c06ffa28410dcef1ac81125a0e to your computer and use it in GitHub Desktop.
Save eddt/398124c06ffa28410dcef1ac81125a0e to your computer and use it in GitHub Desktop.
inserts content after opening body tag
add_filter('template_include','yoursite_template_include',1);
function yoursite_template_include($template) {
ob_start();
return $template;
}
add_filter('shutdown','yoursite_shutdown',0);
function yoursite_shutdown() {
$insert = "\n<!--YOUR INSERTED ". get_option('setting_a') ." HTML GOES HERE-->";
$content = ob_get_clean();
$content = preg_replace('#<body([^>]*)>#i',"<body$1>{$insert}",$content);
echo $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment