A Better Way to Manage Pages in WordPress
One of my major gripes with all CMSes is editing my page content in a textarea. It makes me appreciate working in a native text editor like TextMate: syntax highlighting, keyboard shortcuts, code completion, fast saves, undo, etc. Not to mention working without any version control. Managing page content through a CMS back end is crippling.
So it’s surprising that it took me this long to come up with a better method of managing static pages. All it took was a one-line change to my page template:
// page.php
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<section class="page-content clearfix">
/* <?php the_content(); ?> */ // no more!
<?php include "pages/{$post->post_name}.html.php"; ?>
</section>
<?php endwhile; endif; ?>
Now all my static pages live under a single subdirectory (under version control) with full access to both PHP and WordPress capabilities, and I can edit them just like I edit any other PHP file. Quite a drastic improvement for a one-liner.