<?php
/*
Plugin Name: Custom Home
Plugin URI: http://wordpress.org/support/topic/93438
Description: Display only those posts on your home page with a specific custom field key (and optional value).
Author: Kaf Oseo
Version: R1.0.1
Author URI: http://szub.net

    Copyright (c) 2006 Kaf Oseo (http://szub.net)
    Custom Home is released under the GNU General Public License
    (GPL) http://www.gnu.org/licenses/gpl.txt

    This is a WordPress 2 plugin (http://wordpress.org).

Usage:
Make sure to edit the $key and $value variables found within the
szub_custom_home_where() function below for the custom field key
and value to match on. Leaving the $value var empty will cause a
match on custom key only.

~Changelog:
R1.0.1 (Nov-09-2006)
A little fix to the 'where' and 'join' hookups.
*/

function szub_custom_home_where($where) {
/* >> Begin user-configurable variables >> */
//  $key - Custom key to match. Modify to your needs.
    
$key 'home';

//  $value - Custom value to match. Leave empty if you must only match $key.
    
$value '';
/* << End user-configurable variables << */

    
if( is_home() ) {
        global 
$wpdb;

        
$where .= " AND $wpdb->postmeta.meta_key = '$key' ";

        if( 
$value )
            
$where .= " AND $wpdb->postmeta.meta_value = '$value' ";
    }

    return 
$where;
}

function 
szub_custom_home_join($join) {
    global 
$wpdb;

    if( 
is_home() ) {
        
$join .= " LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id ";
    }

    return 
$join;
}

add_filter('posts_where''szub_custom_home_where');
add_filter('posts_join''szub_custom_home_join');
?>