WordPress without WordPress

WordPress
1 Comment

WordPress is one monster of a platform, and hacking it is probably as much fun as you can have with a web page without writing actual code. Unfortunately, that little convenience tends to bring out a lot of “Bubba the Web Alchemist” people out the woodworks that go buck wild with plugins and extensions to do some very, very simple things.

One of the biggest Bubba tasks is to use WordPress as a content management system but providing static pages for some parts of the content for one reason or another. While there is a plugin in WordPress 2.1+ to set a page as a homepage, there are also legitimate reasons to have pages in the WordPress powered page that are not part of the WordPress content database. That reason generally involves a third party web designer that doesn’t know how to code WordPress themes, inept content manager and more. Some people design an entire site from scratch then try to muscle WordPress into it. Some people go the opposite way, they start with WordPress but then have content sections they want to manage outside of WordPress content database.

But what if your template elements relied on WordPress functions?

Big gotcha. Suppose you had a flat web page that you wanted to use as a part of your online content but all your headers and footers had WordPress functions in them – to generate category printouts, archives or comments. You couldn’t just use a bare php include because PHP would crash when it couldn’t interpret the function you are trying to call. So, for all of you struggling Bubba alchemists out there, here is the simplest WordPress-aware page using content outside of the WordPress content database:

<?
define(‘WP_USE_THEMES’, false);
require(‘./wp-blog-header.php’);
get_header();
?>

Bubba the Web Alchemist
<br/>
Global HQ

<?
get_sidebar();
get_footer();
?>

The top section sets up the theme and includes the WordPress functions. get_header() gets the overall site header, and the other functions at the bottom (get_sidebar and get_footer) include the sidebar and footer. This can vary based on your template design but it gets the point across.

The part in the middle is the flat HTML you want displayed in the context of your WordPress theme without giving your webmaster a heart attack. They can go about designing the special pages (forms, surveys, internal/external content and more without bothering you or potentially destroying the WordPress deployment in the process.

See, how easy was that?

One Response to WordPress without WordPress

  1. Nikolaki says:

    Thank you for my first laugh of the day. It’s been crap and I’m grateful for a decent laugh at the end of it.

    “Bubba the Web Alchemist” where’d you come up with that? Genius.

Comments are closed.