I managed to put together a method that changes nothing but index.php (so it’s upgrade-proof). It has the following properties:
- Doesn’t show static category in category listing
- Doesn’t show static posts on front page
- Shows static posts using their own post layout when displayed
- Allows searching of both static and non-static posts, putting all posts in the correct layout
- When you click on a calendar date or search for posts by month or day, you see the static post in a slightly altered template that shows the last update (assuming you update your timestamps)
- Doesn’t change index.php, so it’s upgrade-proof!
It also has the following limitations:
- Still sydicates entries through RSS (if timestamp is updated)
- May require alteration of plugins/hacks that lists posts on front page, because it doesn’t unset the static posts, just chooses whether or not to display them
Basically, it just requires the addition of an if-else statement in the posts loop, and one quick change to the menu.
First, the menu. Change the categories list to exclude your static category like so:
<?php wp_list_cats('exclude=3'); ?>
Adding the exclude statement (and of course replacing with the ID of your static category) takes care of that part. Now, to change the loop. Immediately after these two lines:
<div id="content">
<?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
add the following beginning to the if statement:
<?php if (!in_category(3)) { //begin regular loop ?>
Now, once the regular loop has finished, we close the if statement and start the elseif statement that will show the static page under specific conditions. Find the following code:
<?php include(ABSPATH . 'wp-comments.php'); ?>
</div>
Immediately after it insert:
<?php
} //end regular loop
elseif ($single==true || !empty($search) || !empty($cat) || intval($monthnum)) { //begin static pages loop ?>
The parameters of the elseif statement can of course be modified to meet your needs. Now, we just create a static content layout of our own choosing. Here’s what I recommend:
<?php
if ($single) { ?>
<h2 class='static'>/static/<?php echo $post->post_name; ?>/">
<?php the_title(); ?>
</h2>
<? }
else the_date('','<h2>','</h2>');
?>
<?php if (!$single) { ?>
<h3 class="storytitle" id="post-<?php the_ID(); ?>">/static/<?php echo $post->post_name; ?>/"><?php the_title(); ?> - Updated</h3>
<?php } ?>
<div class="storycontent"><?php the_content(); ?></div>
<div class="meta" id="static">Last updated <?php the_date('','',''); ?> by <?php the_author(); ?>.</div>
<?php } //end static pages loop ?>
Let me know how this works for you.