Using OB (Output Buffering) for better result in view Wordpress

even you developing wordpress, when add code in function.php and you using it in a page and showing a broke template?

maybe its will help you.

Prefer using ob (output buffering) for better result, so you can use this syntax :



function getTemplate($file) {

    ob_start(); // start output buffer
    // you can add html or include html here
    include $file;
    $template = ob_get_contents(); // get contents of buffer
    ob_end_clean();
    return $template;

}
 
 
Maybe useful for you, thank you for visiting my blog

Comments