Some WordPress themes include custom page templates that let you add a custom layout or some nifty feature to specific pages. But sometimes you need the exact opposite – a page to be as bare, unadorned, downright plain as possible. No header, no menus, no nothing – just the HTML that you entered in the page editor. Luckily, this can also be achieved with page templates.
I recently ran into this problem myself when working on one of my WordPress sites – I needed a template that wouldn’t render any of the normal theme elements (header, sidebar, comments, and so on), but still display the page content and let most of the plugins work correctly. So I wrote a bunch of extremely bare-bones page templates for situations like that, which I’ll share with you today.
The Bare Necessities
I created four variants of the “bare-bones” page template :
- Minimal header & footer
Includes the minimum header and footer HTML necessary to create a (semi-)valid HTML page. Outputs only the page content – no title or meta info. Theme style sheets are ignored. Content filters are applied, so things like newlines being turned into paragraphs & graphical smileys will work. Most plugins that add their code in the page header, post content or the page footer should work.
- Minimal header & footer (unfiltered)
Same as above, except that the page content isn’t filtered. WordPress will no longer turn newlines into paragraphs or apply any other HTML filters to the page content. Plugins that add stuff to the content will not affect a page that has this template applied.
- No theme HTML
This template displays only the page content. No other HTML will be generated – not even the opening and closing <html> tags. Automatic paragraphs and other content filters are active.
- No theme HTML (unfiltered)
Download The Templates
This ZIP archive contains all four page templates. To install them, copy the .php files to your theme’s directory. For example, if your theme files are located in
/wp-content/themes/cool_theme/, copy the page templates to that directory. The templates should work with any theme.
Caution! There’s a good chance that some plugins will not work correctly on pages that use one of these templates.
To some, this might seem like a needlessly complicated way to get custom/unfiltered HTML into a WordPress page. Why not just put the custom code in the page template itself and be done with it? In my opinion, there are two advantages to general-purpose templates :
- Universality & reuse – say you have several pages of the bare-bones sort on your site and you need to add some kind of customization to all of them. If each of those pages is a separate template, you’ll need to edit each file separately. This is a lot of work and makes it easier to miss something. If all of them use the same general-purpose minimalistic template, you just need to edit that one template.
- Plugins work (mostly) – unless you select the “unfiltered” version of the templates, most shortcodes and other plugin-dependent features should still work on your “bare-bones” pages. This can be done with page-specific templates, but it would require some ugly hacks.
Finally, I just love general solutions 😉
Image credit : ilco @ sxc.huRelated posts :