Using WordPress as a True CMS

Using WordPress as a True CMS

OK, so everybody is always talking about how WordPress is no longer a simple blogging platform but a true CMS.

This is true, WordPress can be put to use for a wide variety of websites, whether it be a local community website or, especially with the help of WPMUdev.org, a fully-fledged social networking arena.

However, there are a few things that you can do to truly revolutionize your website, and to make it much more of a CMS than is currently available via most themes, and that is what this article is all about.

This has been written for those who are new to WordPress, as well as seasoned users, so there will be certain things here that may be obvious to many users, such as how to use a nicer permalink structure or create a page template, but just skip those sections, as there may be a hidden gem here that will give you that excited feeling we get, and have you rushing off to test some code. For those of you looking to branch out form the norm, take a look, and this may give you some pointers.

Changing Your WordPress Permalinks

Don’t you just hate those URL’s you get when using the default setup of WordPress that look something like:

http://YOURSITE.com/?p=123

They really don’t help with your Google rating at all, and that is something that should make you rush to make changes.

I always use the following format, and believe that this is what many others use also:

http://YOURSITE.com/categoryname/posttitle

To do this, go to Settings>>Permalinks & select the Custom Structure, and type in:

/%category%/%postname%/

This structure is fine for smaller blogs but may cause performance problems with larger sites.  To find out more about this, take a look at this article.

How To Set a Static Page in WordPress

Nothing looks more bloggy than a home page with a list of latest posts.

This is why you may want to consider using one of your pages as the home page instead of the traditional one.

To do this, go to Settings>>Reading and select the page that you would like to use as your home page.

Creating Page Templates in WordPress

To create a different look for different pages, you just need to create new page files, which can then be uploaded to your main theme’s folder and selected from a drop-down menu whenever a page is created or edited.

The easiest way to do this, is to edit the current page.php file, and make your changes to it, save it under a different name, such as page2.php, and then select it if you want to use that design.

Of course, it would be best to name it something more descriptive, especially if you create a variety of different templates, as you will then know where you are when editing pages.

At the top of the new template page, you will need to have the following:

<?php

/*

Template Name: YOUR TEMPLATE NAME

*/
?>

Creating Category and Post Templates in WordPress

There are ways to create a different look to various categories by hard-coding, but there is a much simpler way, and that is by using the Idealien Category Enhancements plugin.

Not only will this allow you to have a different look to the category.php page but, depending on the category you are in, it also allows you to have a specific look to all posts in a certain category/sub-category.

This involves adding code at the top of each edited category page, in the same way as with the page template above. This code is:

<?php /*
Category Template: Custom Template Name
*/ ?>

I have found that the section of this plugin that deals with linking in your seperate single.php files does not always work correctly, as it doesn’t seem to call the seperate file.

If this happens, then don’t panic, as there is a plugin that deals with this very nicely.

The Single Post Template plugin allows you to easily add as many templates to your create/edit posts section of admin, and you can then select the template you wish to use for each post.  This is probably a much better way to deal with it if your posts are in multiple categories, as you get to choose which template to use.

Simple Redirection in WordPress

If you want to have full control over your menus, enabling you to link easily to posts or external links from a page menu, this is very simple to do, with very little editing.

Open your page.php file, and find the following:

<?php get_header(); ?>

Change this to the following:

<?php
global $post; // < — globalize, just in case
$field = get_post_meta($post->ID, ‘redirect’, true);
if($field) wp_redirect(clean_url($field), 301);
get_header();?>

Once you have done this, you can create a simple redirect by creating a new page and using the custom fields section.

Name: redirect
Value: FULL URL TO WHERE YOU WANT TO REDIRECT

Showing Alternate Headers on your WordPress Pages and Posts

If you want to show different headers, depending on which part of your site users are on, you can do this by replacing a single line of code.

Find the following line of code in a file such as page.php, single.php, category.php, etc:

<?php get_header(); ?>

Replace this with this code:

<?php include (‘ALTERNATEFILE.php’); ?>

To make this easy on yourself, you should use alternate names such as header-portfolio.php, header-blog.php, header-gallery.php, etc.

Calling Alternate style.css files in WordPress

So, you have a different header for various sections of your site, but the CSS is all the same. Why not have a seperate CSS file for different areas of your site?

Again, this is done by simply replacing a single line of code.

Find this code (or something similar):

<style type=”text/css” media=”screen”><!– @import url( <?php bloginfo(‘stylesheet_url’); ?> ); –></style>

Replace it with this code:

<link rel=”stylesheet” href=”/wp-content/themes/imwp/style2.css” type=”text/css” media=”screen” />

I hope that this article has shown you a few things you may not have known about, and will enable you to make WordPress work for you as a CMS more than ever.

I am currently working on a website that includes all of these methods, so why not take a look at it and see it in action:

www.moonworksfestivals.com

Plugin Downloads

These are the two plugins discussed above, in the category/post/page templates section.

Idealien Category Enhancements

Single Post Template Plugin