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 1 out of 2)

Introduction

WordPress is a powerful blogging tool, licensed under the GPL license, and used by thousands of people around the world. Although WordPress is primarily known as a blogging tool, it is just so much more. With a few modifications, plugins and custom templates it's possible to use WordPress as a content management system.

In this two-part tutorial I will show you exactly how to transform WP from a blogging tool into a full-blown CMS. In this part I will provide an introduction to plugins and templates, and explain how they work, and how to use them to your advantage. In the next part I will guide you through the steps necessary to use WP as a CMS.

WordPress Plugins

Plugins are a great way to add extra functionality to your WP installation, without having to edit any files at all. Plugins work by using filters and actions, and if you combine these two things plugins are able to do almost anything. Filters are functions that modify WP content stored in your database, before it gets displayed. They are a great way to provide extra formatting or to change something on-the-fly. Actions are functions that specify additional events, which means you can extend almost any task that WP does.

Let's have a look at a simple plugin. Copy the code below, and save it as myplugin.php in your wp-content/plugins folder (it's located in your WP directory). Then go to your Plugin manager, and you should see a new plugin called 'My Plugin'. Activate the plugin, and view one of your blog entries.

/*
Plugin Name: My Plugin
Plugin URI: http://phpit.net
Feed URI: http://phpit.net/feed/
Description: Our test plugin
Version: 1.0
Author: Dennis Pallett
Author URI: http://phpit.net
*/

function my_test ($str) {
        $str .= ' TEST!';
        return $str;
}

// Add Our Plugin Filter
add_filter('the_content', 'my_test', 9);

?>

As you can see we've just added a filter for the content of an entry. That's pretty much how filters work, and you can change almost any type of content in WP. See the WordPress Codex for a complete list.

Let's also have our plugin use an action. Copy the code below, and save it in myplugin.php again. Just overwrite the previous code. Then refresh the Admin CP.

/*
Plugin Name: My Plugin
Plugin URI: http://phpit.net
Feed URI: http://phpit.net/feed/
Description: Our test plugin
Version: 1.0
Author: Dennis Pallett
Author URI: http://phpit.net
*/

function my_test () {
        // Use the add_menu_page to add a new top-level menu
        add_menu_page('Test Menu', 'Test', 3, 'bla.php');
}

// Add Our Plugin Action
add_action('admin_menu', 'my_test', 10);

?>

Our plugin has added a new menu to the Admin CP. This is just a really simple example of what an action can do, and there is much more possible. To view the full list of actions, have a look at the Codex again.

This is how plugins work, and creating your own plugins is extremely easy. But many plugins already exist, and some of them can be really useful when you're creating a CMS out of WP.

First of all, I recommend installing the PHP Exec plugin, which will allow you to use PHP in your posts and pages. This plugin is great for creating dynamic pages or even creating dynamic posts. Next, you might want to consider installing some formatting plugins, such as the ig:Syntax Hiliter plugin, which is used to highlight code examples. Of course, if you don't run a technical website, you don't need this, but if you do, then this is definitely a plugin you will want to install.

Have a look on WP-Plugins.net for a full list of all the available plugins, many of which are very useful.

Next: WordPress Templates »



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