Using Wordpress as a CMS

February 26, 2007 – 2:45 pm

When you hear the name wordpress, what comes in your mind is a blog as it has become widely used blogging software. But it is much advanced software than a simple blogging tool where you can have a blog post live within a flash.

Wordpress has support for pages as well as posts. Pages, well you would have used pages in wordpress to create an ‘About Us’ page or a contact page, but with an extensive use of the page feature of wordpress you can have a custom made CMS up and running.

I started as a newbie in wordpress a few months ago, setting up this blog with my nickname. Recently I got a new project from my work place to develop a custom made CMS. I am not familiar with Drupal or mambo, but I have seen in digital point forums that wordpress can be used as a CMS, but I couldn’t find a tutorial on how to do that.

Before starting the project, I wanted some match practice, so I decided to convert one of my websites into a simple CMS system.

In wordpress, by default home page displays a number of posts from the recent one you have just made. But wordpress is developed by intelligent people who have kept provisions to make the home page or any other page as we wish.

First thing you need to know is that, its the theme pages which is getting displayed in the front end when you view a page or post, so our starting point is the custom theme you have selected for your blog / cms website.

Basically one will find following files in your selected theme folder

* style.css

* index.php

* header.php

* sidebar.php

* footer.php

* comments.php

* comments-popup.php

First step, you need a home page which is different from the typical blog home page and should contain home page content.

Save a copy of index.php as in theme folder and rename it as home.php

Go to the dashboard, create a new page entering page content, title everything and enter the page slug as home (i.e the file name you just saved).

Edit your home.php

You can see a function call something like this in very beginning.

<?php

get_header();

?>

Now change that to

<?php

get_header();

query_posts(’pagename=home’);

?>

query_posts is a wordpress function where you can forcibly show a page according to the parameter you are passing. Here the parameter pagename is given as home which the page slug.

Once you do this much, save home.php and when you open home page, you will see the home page you created instead of the normal wordpress home page. Of course the content will be what you entered when you created the home page from dashboard.

How this happened? Well.. I told earlier, wordpress is developed in such a manner where you can twist wordpress into whatever way you want!!

Its called Page Hierarchy in wordpress. Typically wordpress looks for ’slug’.php for whatever page you create with a page slug. If ’slug’.php is not present, it shows index.php content. In our case, page slug was home which had priority over index.php when home page was viewed.

Now you have successfully converted your blog to look like a CMS in the homepage.

Now to make into a complete CMS, I suggest you to use the page feature rather than the categories and posts. Another thing to note is that a page can have child pages just like in normal websites. For example you have a page called Spain and there is a child for Spain, which is Alicante. So you can have a page hierarchy

Home -> Spain -> Alicante

So you can have a structure like site.com/spain/alicante/ etc

next steps are a bit complex as it requires that you go through the function reference of wordpress.

Basically you shuld know how to use functions like

wp_list_pages

get_permalink

is_page etc etc (which never ends !!)

It took me 2 days to convert my website Cheap Flight to a simple CMS system even being not a wordpress expert. My strengths are a bit of programming knowledge in PHP and an ability to explore and grasp developer documentations and courage to experiment.

I am sure that this one post is not sufficient to explain how I exactly transformed my website into a CMS powered by wordpress, but I will certainly try to put in some more time to explain a bit more.

Few pages I referred are

From Weblog to CMS with WordPress - Which helped in creating a customized home page
Wordpress Function Reference - A must to see information where you can see the API’s and select which wordpress functions to use and when.

Post a Comment