I installed a WordPress blog on my development server the other day and began playing with it. The first real challenge I faced was how to pull my WordPress installation into my Web site’s template.
My issue is, I’m using a content management system (CMS) to manage the bulk of my Web site’s content. However, I wanted to use WordPress to manage my various blogs. I obviously wanted my blogs to look like the rest of my Web site, so I needed to come up with a plan to integrate my WordPress installation into my CMS, somehow.
Basically, what it came down to was that I needed to find a way to store all of my WordPress output into PHP variables. Once I had done that, I could plug those variables into my template. The main problem I ran across, however, was the fact that 99% of the functions WordPress uses to build its output utilize echo commands rather than simply returning the output.
That was no good for me, obviously, as it started printing content onto my page before the template had been processed.
PHP came to my rescue, and with very little headache. PHP’s output buffer was the simple answer to my problem.