You are reading...

March 28th

Keeping Wordpress’ core features when using it as a CMS

A recent project involves using WordPress as a CMS. Even if your WordPress site is not a blog, it always good to take advantage of WordPress’s strongest feature, which is the “posts” section and the WordPress loop.

The project is a work in progress, so I do not have a finished example. Basically, I created a blank WordPress “page” that uses a custom template file. This template file contains different parts of the loop. In my case, each page contains a loop based on category, but one can use tags, dates, etc. Here’s a rough example.

<?php query_posts('showposts=5'); ?>
        <?php $posts = get_posts('numberposts=5&offset=0&category=3');
foreach ($posts as $post) : start_wp(); ?>
		<div class="post" id="post-<?php the_ID(); ?>">
				<h4><?php the_title(); ?></h4>
				<span><?php the_time('F j, Y') ?></span>

                <div class="entry">
               		<?php the_content('Read the rest of this entry »'); ?>

<?php endforeach; ?>

In this example, I first request posts from my loop, then I define my loop as only entries with category ID of 3.

That way, when I hand off the project to a client, he can manage his website through the fully featured “post” section of WordPress instead of the “page” section or editing the template files directly. So when using WordPress as a CMS, if you need something usable it’s best to resort to using WordPress’ core features.

Go home