0

I am trying to use mustache within a wordpress application and modularize it. I would like to use mustache partials to inject the header and footer string into individual template files.

However, as soon as I call get_header / get_footer on the controller layer, the header and footer are echo'ed out immediately. What I am trying to do is just retrieve the markup from the header and footer and store it into a variable, for 'later' injection into the template is this possible?

Thanks in advance!

  • theses functions don't use filters. then to custom header and footer, you can create your own functions in your theme. – mmm Oct 23 '17 at 19:05
3

Use an output buffer!

ob_start();
get_header();
$header = ob_get_contents();
ob_end_clean();

The header is now in $header and you can do with it as you please.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.