Customizing WordPress as a CMS finishing touches

My last couple of posts I’ve talked about how to customize WordPress to create your own theme and templates. As I talked about in this post I feel that WordPress is a hugely powerful CMS admin system but falls behind with its front-end publishing capabilities. I don’t like how it publishes the HTML and in this post I will give some hints as to how to completely abandon the WordPress front-end for your own.

Custom Permalinks
By default all pages are created as something like ‘http://www.mysite.com/?p=14′. But WordPress has it’s own built-in URL parser and router allowing us to make pretty URLs. Click ‘Settings->Permalinks’ in the left sidebar and select the ‘Month and name’ radio button and hit save (don’t worry about the other options, they really only affect the “posts” URL structure and we’re only concentrating on “pages” here).

It creates an ‘.htaccess’ file in the web root, if Apache doesn’t have permission to create this file then you can create it yourself with the following:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Basically every file that doesn’t exist (media, css, js, etc. files that physically exist bypass the rule) gets sent to the index.php file which does a URL lookup and routes to the correct template.

You can now go and look at a custom page you’ve made and see it has a beautified URL as a Permalink.

Custom Header and Footer
The default WordPress header and footer does a lot of automatic work. In order to free your code from this I recommend creating you own header and footer. Any functionality that the header and footer contains that you want to keep can be ported over as you need it.

In your theme folder create your own header.php and footer.php files. It’s probably a good idea to save a backup first (even though you’ll probably already have the whole thing backed-up from when you created your own theme, and then get rid of everything in the files you don’t want. For example when I first started experimenting I kept all the boiler plate stuff and ditched the automatic navigation generation and sidebar code. Start with the minimum and work things back in from your template as you need them, if you feel you need them, personally I rewrote everything back in.

Once you understand what you’re doing here you can drop the whole header and footer approach and use a templating engine such as Sigma (which I’ve favored for some time).

Custom Homepage
The final move is to set the homepage as something other that the blog. This is the final key in freeing up WordPress from being a blog tool dependent on the default code to becoming, well anything you want from a website, backed by a powerful CMS. Of course you will also always have the option to quickly and easily implement a powerful blogging system into your site, but the point is the blog doesn’t actually have to be your site.

In your admin panel create a new page with the title ‘HOMEPAGE’, I recommend to first create a homepage template because a homepage is never like anything else. Once you have that page published navigate to ‘Settings->Reading’ and under the first option ‘Front page displays’ select the second radio button ‘A static page (select below)’, and in the drop-down find the ‘HOMEPAGE’ page you just created, and save your changes.

That’s it, you’re now free to go crazy with your website design and code yet still harness the power that the WordPress CMS yields! And don’t forget if you want to have a blog in your website, now or in the future, you already have all the tools you could want.

This is part of an ongoing series of posts I am publishing talking about how to use WordPress as a custom CMS.

Leave a Reply