Note: this is one of a series of posts about the creation of the King Design web site.
I’ve used WordPress as a web site CMS in the past, I think with version 1.0.1 and 1.2.x – and let me tell you that version 1.5 is definitely the easiest version yet to use as a CMS.
In the past, I’ve used categories as sections with posts as pages. I created my own version of the edit interface that listed the posts in each category rather than the standard chronological listing. I handled different categories by including different template files – for example, the news page should be a list of news items first, while a product information page should show content. Some of the custom coding in this process is no longer needed in 1.5.
For the King Design web site, I decided to
It became clear very quickly that I was going to need to either create very specific page type templates, or find a way to execute PHP from within the code for the posts and pages. Luckily, RunPHP had already been written and it works great. For example, the sub-navigation and sidebars on the Tasks and Tasks Jr. pages are actually included code that are page aware and behave correctly depending on the page in which they are included.
I decided to use the ‘Pages’1 feature in WordPress for the main content of the site. The home page, product pages, contact page, etc. are all ‘pages’. For the FAQs and News, I’m using ‘Posts’. This is an obvious call for date based information like news items, but there are more subtle reasons for using posts for the FAQs.
As I previously discussed, search is important. One of the search features I wanted to have in the site was the ability to restrict the search to certain areas of the site.2 By making the FAQs posts and putting them all within the FAQ category, it becomes much easier to manage them as a group. Pages can technically have categories attached to them (the schema supports it), but the default interface doesn’t provide access to those features. I decided it would be best to go with the way WordPress already works instead of hacking in support for additional configuration. Also, WordPress has built-in support for category RSS feeds.
Once I set up all my pages and set up the News and FAQs as posts, I then ran into an issue with the Apache mod-rewrite rules. WordPress does a great job of generating these rules, but if you’re managing the site structure yourself, you need to take control of this as well. I did try to set up my pages as closely as possible to match the URLs I wanted, but in some situations it just wasn’t possible.
News items, for example, have URLs similar to a standard blog structure:
however the structure for FAQs is entirely different:
To handle these differences, I had to manage the mod-rewrite rules manually. Remember to make your .htaccess unwritable by the Apache user, or WordPress will add rules on you, often resulting in a 500 Internal Server Error.
Since there were going to be pages with mod-rewrite locations like ‘/download/’, I needed a solution for where to put the physical ‘download’ directory that I wanted to put certain files in. The solution I decided on was to create a ‘static’ directory, with a structure that mirrored the psuedo structure created by the mod-rewrite rules. Then I added a mod-rewrite rule to check in that location for anything that wasn’t already caught by another rule.
For example, the URL:
is really hitting this physical location:
This makes is easy for me to manage file downloads and to integrate installations of other systems at proper URLs without having them clash with the mod-rewrite rules needed for the WordPress content.
I’m very happy using WordPress as a CMS. I plan to convert alexking.org to WordPress (using similar techniques) in the future, just need to find some roundtuit.