I have a couple pages such as my password generate that are non wordpress templates. However I want these to be styled as if they where from my wordpress. So after some google searches, I came up with very little information. I decided to dive into the code and came up with something that works for what I need it to do and requires little code edits to any of my pages to work.
This does also require a template edit to your wordpress templates. Sadly I couldn’t avoid this, I looked around and tried to see if I could modify the_content(), however it doesn’t look very pleasant to do so. I might in the future look into doing this. If somebody has a better solution that requires no wordpress template edits, please let me know. Back on topic, I modified page.php in my template and changed:
<?php the_content(); ?>
To this line:
<?php if (isset($specialPageContent)) echo $specialPageContent; else the_content(); ?>
Next I will just dump a file I named wp-ssi.php and explain how it works at the end.
// Change the default template to use.
// Register a shutdown function (DOES THE ACTUAL WORK!)
// Don't output anything yet.
// Get Wordpress going.
// The shutdown function that does the actual work.
// Simply get all contents.
$specialPageContent = ob_get_clean();
// Allow some over rides.
$theme = defined('WP_SSI_THEME') ? WP_SSI_THEME : get_template_directory();
$template = defined('WP_SSI_TEMPLATE') ? WP_SSI_TEMPLATE : WP_SSI_DEFAULT_TEMPLATE;
// Pass it on as if it was a page.
require($theme . '/' . $template . '.php');
Now for all my files I add at the very top. Of course, you need to substitute the path to match yours.
As for wp-ssi.php, I will can explain more about how that works.