So, you want this?
(source: mikeschinkel.com)
Alright, here ya go:
<?php
/*
Plugin name: Static Content
*/
if (!class_exists('YourSite_StaticContent')) {
class YourSite_StaticContent {
static function on_load() {
add_action('init',array(__CLASS__,'init'));
add_filter('manage_static_content_posts_columns',
array(__CLASS__,'manage_static_content_posts_columns'));
add_filter('manage_posts_custom_column',
array(__CLASS__,'manage_posts_custom_column'),10,2);
add_action('restrict_manage_posts',
array(__CLASS__,'restrict_manage_posts'));
add_filter('parse_query',
array(__CLASS__,'parse_query'));
}
static function init() {
register_post_type('static_content',array(
'labels' => array(
'name' => __( 'Static Content' ),
'singular_name' => __( 'Static Content' ),
'add_new_item' => 'Add New Static Content',
'edit_item' => 'Edit Static Content',
'new_item' => 'New Static Content',
'search_items' => 'Search Static Content',
'not_found' => 'No Static Content found',
'not_found_in_trash' => 'No Static Content found in trash',
),
'public' => true,
'hierarchical' => false,
'taxonomies' => array( 'section'),
'supports' => array('title','editor','excerpt'),
'rewrite' => array('slug'=>'static_content','with_front'=>false),
));
register_taxonomy('section','static_content',array(
'hierarchical' => true,
'labels' => array(
'name' => __( 'Section' ),
'singular_name' => __( 'Section' ),
'add_new_item' => 'Add New Section',
'edit_item' => 'Edit Section',
'new_item' => 'New Section',
'search_items' => 'Search Section',
'not_found' => 'No Sections found',
'not_found_in_trash' => 'No Sections found in trash',
'all_items' => __( 'All Sections' ),
),
'query_var' => true,
'rewrite' => array( 'slug' => 'section' ),
));
if (!get_option('yoursite-static-content-initialized')) {
$terms = array(
'Footer',
'Header',
'Front Page Intro',
'Front Page Content',
);
foreach($terms as $term) {
if (!get_term_by('name',$term,'section')) {
wp_insert_term($term, 'section');
}
}
update_option('yoursite-static-content-initialized',true);
}
}
function manage_static_content_posts_columns($columns){
$new = array();
foreach($columns as $key => $title) {
if ($key=='author') // Put the Sections column before the Author column
$new['sections'] = 'Sections';
$new[$key] = $title;
}
return $new;
}
function manage_posts_custom_column( $column,$post_id ) {
global $typenow;
if ($typenow=='static_content') {
$taxonomy = 'section';
switch ($column) {
case 'sections':
$sections = get_the_terms($post_id,$taxonomy);
if (is_array($sections)) {
foreach($sections as $key => $section) {
$edit_link = get_term_link($section,$taxonomy);
$sections[$key] = '<a href="'.$edit_link.'">' . $section->name . '</a>';
}
echo implode(' | ',$sections);
}
break;
}
}
}
function parse_query($query) {
global $pagenow;
$qv = &$query->query_vars;
if ($pagenow=='edit.php' &&
isset($qv['taxonomy']) && $qv['taxonomy']=='section' &&
isset($qv['term']) && is_numeric($qv['term'])) {
$term = get_term_by('id',$qv['term'],'section');
$qv['term'] = $term->slug;
}
}
function restrict_manage_posts() {
global $typenow;
global $wp_query;
if ($typenow=='static_content') {
$taxonomy = 'section';
$section = get_taxonomy($taxonomy);
wp_dropdown_categories(array(
'show_option_all' => __("Show All {$section->label}"),
'taxonomy' => $taxonomy,
'name' => $taxonomy,
'orderby' => 'name',
'selected' => $wp_query->query['term'],
'hierarchical' => true,
'depth' => 3,
'show_count' => true, // This will give a view
'hide_empty' => true, // This will give false positives, i.e. one's not empty related to the other terms. TODO: Fix that
));
}
}
}
YourSite_StaticContent::on_load();
}