WordPress as CMS

I have read many useful (and also some less useful) comments how to squeeze WordPress to work as a CMS.

I did not want to make any major changes to scripts that would be lost after an upgrade. I did not want to have extra plugins to change home (for example by creating an overriding home.cfm). I did not want to have any new categories. I did not want to change permalink structure. I still need my directory plugin to work, I still need the blog (some redirects even loose the blog address!) and I wanted to keep the RSS feed.

After several hours I came up with an very simple solution: Take a standard page and rename its title and slug to “Home” – assign a special “Home” template – redirect htaccess to this page. The only trick is to make the “Home” template work: it is basically a copy of the index.cfm in your WordPress theme directory where the line calling loop.php is being replaced with a slightly modifed loop code.

myblog.php

 1:
 2:
 3:
 4:
 5:
 6:
 7:
 8:
 9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
28:
<?php
/*
Template Name:MyBlog
*/
?>

<?php get_header(); ?>
<?php get_sidebar
(); ?>

<div id="primary">
<?php query_posts('showposts=5'); ?>
<?php 
while(have_posts()) : the_post(); if(!($first_post == $post->ID)) : ?>
    <div class="entry">
        <div class="post-meta">
            <h2 class="post-title" id="post-<?php the_ID(); ?>"><?php if(!is_single()) { ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a><?php } else { the_title(); } ?></h2>
            <p class="post-metadata"><?php the_time('l, F jS'?><?php if(!get_option('tarski_hide_categories')) { ?> in <?php the_category(', '); ?><?php ?><?php /* If there is more than one author, show author's name */ $count_users $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->usermeta WHERE `meta_key` = '" $table_prefix "user_level' AND `meta_value` > 1"); if ($count_users 1) { ?> by <?php the_author_posts_link(); } ?> | <?php comments_popup_link('No comments''1 comment''% comments''''Comments closed'); ?><?php edit_post_link('Edit',' (',')'); ?></p>
        </div>
        <div class="post-content">
            <?php the_content(' more &raquo;&raquo;&raquo;'); ?>
            <p class="tagdata"><?php _e('Tags: '); UTW_ShowTagsForCurrentPost("commalist"?> | <?php _e('Trackback: '); ?>
            <a href="<?php the_permalink() ?>trackback/">link</a></p>
        </div>
    </div>
<?php endif; endwhile; ?>
</div>

<?php get_footer(); ?>