• This is the code, i have added only the last filter for add a custom order of posts…..but with my addition the plugin doesn’t work…

    <?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 = 'voto';
    
    //  $value - Custom value to match. Leave empty if you must only match $key.
    	$value = '';
    /* << End user-configurable variables << */
    
    	if( is_category() ) {
    		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_category() ) {
    		$join .= " LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id ";
    	}
    
    	return $join;
    }
    
    function szub_custom_home_orderby($orderby) {
    	global $wpdb;
    
    	if( is_category() ) {
    		$orderby .= " $wpdb->postmeta.meta_value ASC ";
    	}
    
    	return $orderby;
    }
    
    add_filter('posts_where', 'szub_custom_home_where');
    add_filter('posts_join', 'szub_custom_home_join');
    add_filter('posts_orderby', 'szub_custom_home_orderby');
    ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Please help me with this easy plugin’ is closed to new replies.