WordPress.org

Support

Support » Plugins and Hacks » hook the body tag

hook the body tag

  • is there any way of using this code only on the frontend of wordpress and not in the backend?

    I get “YOUR INSERTED HTML GOES HERE” in the admin area also. which i dont want but i need to “hook” the body tag.

    <?php
    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 =  "[YOUR INSERTED HTML GOES HERE]";
    	$content = ob_get_clean();
    	$content = preg_replace('#<body([^>]*)>#i',"<body$1>{$insert}",$content);
    	echo $content;
    }
    ?>
  • The topic ‘hook the body tag’ is closed to new replies.