ASPit - Totally ASP JSit - Totally JavaScript
Search PHPit

Use this textbox to search for articles on PHPit. Seperate keywords with a space.

Advertisements

Using WordPress as a Content Management System, Part 1

(Page 2 out of 2)

WordPress Templates

Changing the look of your WordPress website is extremely easy with the Theme Editor, and the great thing about WP templates is that they're PHP based. This might seem a bit unfriendly towards beginners, but it's great for us, because it means we have a lot to work with.

If you don't know anything about the WP template system, I highly suggest you play with it for a few hours. Get to know how it works and start learning some of the template tags. A great place to start is at the Codex, especially the Template Tags section.

A little know feature of the WP template system is that you can very easily add your own templates. Just create a new file with the following in it, and save it in your wp-content/theme/[theme name]/ folder.


/*
Template Name: My Template
*/

?>
HTML and PHP goes here

If you now look in your theme editor your template should now appear in the templates list, and it's possible to create as many templates as you want.

Let's have a look at creating a custom template for a certain category. As we can read in the WP Codex for 'Category Templates', WP looks for a category template in the following order:

category-[catid].php
category.php
archive.php
index.php

This means we can create a custom category template by creating a new template, saved as category-1.php (that would display a custom template for the category that belongs to categoryID 1). Copy the code below, and save it as category-1.php (or category-[another catid].php if you don't have a category with ID 1).


/*
Template Name: Blog Category
*/

?>

get_header(); ?>
get_sidebar(); ?>

My Category

if (have_posts()) : ?>
while (have_posts()) : the_post(); ?>
        POST: the_title(); ?>
endwhile; ?>
else : ?>

               

class="center">Not Found


                include (TEMPLATEPATH . '/searchform.php'); ?>

        endif; ?>
               
get_footer(); ?>

If you now go to the category page for that category, you will see your custom template. Using custom category templates is excellent way of creating separate sections in your WP website, and that's exactly how I've done it here on PHPit. Each section (articles, FAQ, code snippets and blog) is a separate category, and each has its own custom template.

You can also create a custom entry page for each category, but this is slightly trickier. In the next part of this tutorial, I will show you how to do this. Let's have a look at some problems that you may encounter when creating your WP website.

(Common) Problems

Your content gets all mangled
I had a problem whereby my content got all messed up, especially with regard to 'Writing'). Then you must disable the wptexturize filter, by using the remove_filter() function. Add the following to your Header template:


remove_filter ('wptexturize');
?>

Now all formatting options are turned off, and you should no longer experience this problem. If you run a regular content website (e.g. no code in your posts and you don't use PHP Exec), you won't have to disable any formatting.

You want to import your old content
This can often be a problem, because the content of your website is still in your old CMS. If you're starting fresh with WP, you don't have to worry about this, but most of us don't, so you have to think about importing your old content.

For PHPit, I wrote a custom importer that directly imported the old content into the WP database. But this might not be possible for everyone, and you should consider using WordPress' inbuilt importers. Have a look on the Codex for Importing Content.

If you really can't do it automatically, you can either consider doing it yourself by hand (takes a lot of time!) or have someone else write you an importing script.

Conclusion

In this first part of the WordPress series, I have given you an introduction to WordPress plugins and templates, and you should now be able to write (simple) plugins yourself. The one thing I can highly suggest is to take a few hours, and simply play with WP. You will learn a lot that way, and gain much experience.

In the second, and final, part I will provide a complete guide on creating a simple website with WP. It will show you from beginning (installing WP) to end (being able to use your website) how to use WP as your content management system.

« Previous: WordPress Plugins



10 Responses to “Using WordPress as a Content Management System, Part 1”

  1. Matthijs Says:

    Thanks for the article. Looking forward to the next installment! Although I’m already quite familiar with wp, articles as these are still very interesting to read. Your tip about how wp searches for templates in a certain order is very handy. Didn’t know that yet.
    My compliments for your site and these articles.

  2. AjiNIMC Says:

    Is there a plugin to integrate wordpress with phpBB , if possible then we can integrate phpBB’s cms system with wordpress

  3. Naveen Says:

    Nice article. In sync with what AjiNIMC said, a plugin to integrate phpBB with Wordpress would be great, more so if the templating system of either (preferably phpBB) is followed by the two.

    Cheers

  4. PHPit - Totally PHP » Using WordPress as a Content Management System, Part 2 Says:

    […] Welcome to part 2 of Using WordPress as a Content Management System series, where in I show you how to use WP as a CMS. In the previous part I have shown you how templates and plugins work, and I talked a little about a few common problems when using WP as a CMS. […]

  5. Matthijs Says:

    One remark about the PHPexec plugin. I read on Christopher ’s site that wp1.6 might give problems with this plugin:
    http://chris.hasenpflug.us/blog/2005/11/16/wordpress-16-and-php-execution
    When 1.6 arrives, the plugin might get updated of course.
    Anyway, might be something to keep an eye on.

  6. 7 seconden » Blog Archive » links for 2005-11-29 Says:

    […] PHPit - Totally PHP » Using WordPress as a Content Management System, Part 1 Ziet er ook veelbelovend uit. (tags: wordpress tutorial) […]

  7. WordPress TestBlog » Blog Archive » some good-looking articles Says:

    […] http://phpit.net/article/using-wordpress-as-a-content-management-system-part-1/ […]

  8. My Crow is Soft » Blog Archive » Using WordPress as a Content Management System, Part 1 Says:

    […] Using WordPress as a Content Management System, Part 1 […]

  9. Il blog sul php » Usare wordpress come content managment system Says:

    […] Continua a leggere su: http://phpit.net/…/management-system-part-1/2/  Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages. […]

  10. wpstuff Says:

    Menu Manager for WordPress.

    http://www.wp-stuff.com/plugins/menu-manager-plugin-for-wordpress.html

Leave a Reply

About the author
Dennis Pallett is the main contributor to PHPit. He owns several websites, including ASPit and Chill2Music. He is currently still studying.
Article Index
  1. WordPress Plugins
  2. WordPress Templates
Bookmark Article
Download Article
PDF
Download this article as a PDF file