<?php
/*
Plugin Name: Keywords
Version: 1.0
Plugin URI: http://www.theonering.net/staff/corvar/software/wordpress.html#keywords
Description: Extract keywords meta on a per post basis.
Author: William "Corvar" Thomas
Author URI: http://www.theonering.net/

This is a simple plugin to append keywords to a static list on a per post basis.

Usage:
If a post add a Custom Field "keywords" with a value of a comma seperated list of the additional keywords you wish.

<META NAME="KEYWORDS" CONTENT="mary,sally,jane,<?php echo keywords(); ?>">

Example:

keywords custom field set to "foo,bar,baz"
Output:
<META NAME="KEYWORDS" CONTENT="mary,sally,jane,mary,sally,jane">

*/

function keywords() {
  global 
$single,$posts,$post_meta_cache;

  
// only act when viewing a single post. Else, exit.
  
if (!$single) return;
    
  
// Get the post
  
$post $posts[0];
    
  
// Get the keys and values of the custom fields:
  
$id $post->ID;
  
$keywords $post_meta_cache[$id]['keywords'];
  if (
count($keywords)) {
    foreach (
$keywords as $word) {
      
$words .= "$word";
    }
  }
  return 
$words;
}

?>