Search code examples
phpwordpresspeartemplate-engine

HTML_Template_IT and wordpress


I want to use PEAR's HTML_Template_IT in one of my Wordpress page templates so I can separate the HTML from the PHP. I got it working, except I am not sure about one thing.

Wordpress's built-in function get_header() actually echo's HTML - so I can't technically set it as a template variable. Is this considered acceptable or is there another way to put the contents of get_header() in a variable?

Thanks!


Solution

  • Well, you could do ob_start() to turn output buffering on, call the function, use ob_get_contents() to get the value that would be echoed and then use ob_end_clean() to erase the buffer and turn buffering off.

    See Output Buffering Control for more.