Bypass head.php and footer.php

I’ve used the Roots theme on several WP projects to good effect, and have been able to generate custom templates pretty smoothly.

I’m now trying to set up a page that completely bypasses not only base.php but also head.php and footer.php. That is because it is for use as a Page that generates an Excel download (with its own HTTP Content Type, document headers, etc. )-- so none of the regular site markup is applicable.

I’ve tried setting up “base-excel.php” template, but I haven’t found guidance on how bypass the regular template wrapping. I suppose I can inject PHP inside head.php etc. – using get_page_template() to suppress all output when it detects my special Excel page template. But maybe there’s a more centralized way I can do it using the filter set up by Roots_Wrapping – as long as it lets me bypass ALL the templates components.

Anyone have any tips about this?

if you created a “base-excel.php” did you also created the “excel.php” template file?

If you create an excel.php template file (copy the content from from template-custom.php), this file will look for base-excel.php to work as its wrapper. You can then, remove your head and footer from your base-excel.php wrapper.

1 Like

Yes, that worked. I had been using base-excel.php as both the base file and as the page template as well, which I see now was incorrect.

Thanks for the help!