Flagging a Post as Outdated Using Wordpress Custom Fields

Posted by Trey on June 14, 2008

If you write a blog whose primary purpose is to help people find and remember information (mostly myself in this case), then it’s probably a good idea to flag certain posts as out-of-date so as not to mislead people who are on a quest for knowledge. That is, of course, if you know it’s outdated. Maybe someone will tell you.

In any case, here’s how you can do it using Custom Fields in WordPress.

Find a post that’s out of date and edit it. Down towards the bottom of the page, there’s a section labeled Custom Fields, click it to open it, and enter something like this:

Create a Custom Field

Use whatever name you want for the key and value, but be sure to change the related fields in the other places I’m about to mention.

I want the notice to show up on the post’s permalink page, so in single.php, I put this right after the start of ‘the loop’:

$status = get_post_meta($post->ID, 'status', true);

As you can probably guess, that just grabs the content for the ’status’ key for the current post and stores it in the variable $status. Easy. If the post doesn’t have the value, the get_post_meta tag is nice enough to fail quietly (as far as I can tell).

Now that you have this very valuable information, you can change CSS, add a warning message, or whatever your little heart desires.

For example:

if ($status == 'outdated') include (TEMPLATEPATH . '/outdated.php');

Sources

Using Something Other Than the Site Root for a Wordpress Posts Page

Posted by Trey on June 09, 2008

This is so you can use something like /blog/ for a list of your blog entries, and the home page for a static page (or something fancier).

Under Settings > Reading > Posts page, pick the page template you want to use.

Setting WordPress Posts page

If you’re using a static page template for the home page, be sure not to name it home.php. Name it something like homepage.php and choose that template for the home page (you can still call it “Home” inside the template).

The “Posts page” will use index.php whether you like it or not. I couldn’t find a way to override that inside of Post management in WordPress.

Installing WordPress The Right Way

Posted by Trey on May 28, 2008

svn co http://svn.automattic.com/wordpress/tags/[current_tag_number] [name_of_site]
cd [name_of_site]
touch .htaccess
chmod 666 .htaccess
cp wp-config-sample.php wp-config.php
cd wp-content/themes/
cp -R default [name_of_theme]
cd [name_of_theme]
rm -rf `find . -type d -name .svn`

Now import the content of wp-content/themes/[name_of_theme] into your choice of source code management systems and get to it.

Updating

 cd [name_of_site]
 svn sw http://svn.automattic.com/wordpress/tags/[new_tag_number]

Sources

Using Subversion to upgrade WordPress

Posted by Trey on October 08, 2006

Update (November 1, 2006): It really works. I’ve got all 3 of my blogs (one two three) now set up on SVN. The next step will to be when I add my customized themes to Subversion so all I ever have to do is go to the command line to do anything. No (s)FTP or anything. I imagine this will make switching servers really easy now.

Update (January 23, 2007): To upgrade to WordPress 2.1:

  1. Disable all plugins (take a screenshot first)
  2. Run this command:
svn switch http://svn.automattic.com/wordpress/branches/2.1/
  1. Go to your admin screen and update the database when prompted.
  2. Enable your plugins again.

Update (May 22, 2007): Just upgraded to version 2.2

Functional WP_Shortstat

Posted by Trey on September 20, 2006

The official wp_shortsat page gives you a version that no longer works with WordPress. Get a good one here. It’s even blue to match the rest of WP Admin.