コード内容：コメントフォームに天気メタ情報を追加するコード例
コードの記述先：functions.php
-------------------------------------------------------
<?php
class comment_meta{
    var $_weather;
    /**
    　* コメントフォームに天気select要素を表示する
    　*/
    function add_comment_element() {
?>
        <label for="weather">今日の天気</label> <select name="weather" id="weather">
            <option>晴れ</option>
            <option>曇り</option>
            <option>雨</option>
        </select>
<?php
    }
    /**
     * コメントフォームから送信された天気をメンバ変数に渡す
     */
    function get_weather($commentdata){
        if( in_array( $commentdata['comment_as_submitted']['POST_weather'], array( '晴れ', '曇り', '雨' ) ) ) {
            $this->_weather = $commentdata['comment_as_submitted']['POST_weather'];
        }
        return $commentdata;
    }
    /**
     * 天気をコメントのメタデータとして保存する
     */
    function add_weather( $id, $comment ){
        add_comment_meta( $id, 'weather', $this->_weather, true );
    }
    function comment_meta(){
        add_action( 'comment_form_logged_in_after', array( &$this, 'add_comment_element' ) );
        add_action( 'comment_form_after_fields', array( &$this, 'add_comment_element' ) );
        add_filter( 'preprocess_comment', array( &$this, 'get_weather' ) );
        add_action( 'wp_insert_comment', array( &$this, 'add_weather' ), 10, 2 );
    }
}
new comment_meta;

function callback_comment( $comment, $args, $depth ) {
    $GLOBALS['comment'] = $comment;
?>
    <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
        <div id="comment-<?php comment_ID(); ?>">
            <div class="comment-author vcard">
                <?php echo get_avatar( $comment, 40 ); ?>
                <?php printf( _ _( '%s <span class="says">says:</span>', 'twentyten' ), sprintf( '<cite class="fn">%s</cite>',  get_comment_author_link() ) ); ?>
            </div><!-- .comment-author .vcard -->
            <?php if ( $comment->comment_approved == '0' ) : ?>
                <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>
                <br />
            <?php endif; ?>
            <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
<?php
            /* translators: 1: date, 2: time */
            printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
?>
<?php
            $weather = get_comment_meta( get_comment_ID(), 'weather', true );
            if( $weather ) printf( '<span>(%s)</span>', $weather );
?>
        </div><!-- .comment-meta .commentmetadata -->
        <div class="comment-body"><?php comment_text(); ?></div>
        <div class="reply">
            <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
        </div><!-- .reply -->
    </div><!-- #comment-## -->
<?php
}
?>
-------------------------------------------------------


コード内容：コメント出力コード例
コードの記述先：comments.php
-------------------------------------------------------
<?php wp_list_comments( array( 'type' => 'comment', 'callback' => 'callback_comment' ) ); ?>
-------------------------------------------------------


コード内容：追加した項目を管理画面で確認する
コードの記述先：functions.php
-------------------------------------------------------
<?php
class comment_meta{
    var $_weather;
    /**
    　* コメントフォームに天気select要素を表示する
    　*/
    function add_comment_element() {
?>
        <label for="weather">今日の天気</label> <select name="weather" id="weather">
            <option>晴れ</option>
            <option>曇り</option>
            <option>雨</option>
        </select>
<?php
    }
    /**
     * コメントフォームから送信された天気をメンバ変数に渡す
     */
    function get_weather($commentdata){
        if( in_array( $commentdata['comment_as_submitted']['POST_weather'], array( '晴れ', '曇り', '雨' ) ) ) {
            $this->_weather = $commentdata['comment_as_submitted']['POST_weather'];
        }
        return $commentdata;
    }
    /**
     * 天気をコメントのメタデータとして保存する
     */
    function add_weather( $id, $comment ){
        add_comment_meta( $id, 'weather', $this->_weather, true );
    }
    /**
     * 保存されているメタデータを更新
     */
    function update_weather( $id ){
        if( in_array( $_POST['weather'], array( '晴れ', '曇り', '雨' ) ) ){
            update_comment_meta( $id, 'weather', $_POST['weather'] );
        }
    }
    /**
     * コメントのリスト表示に天気を追加
     */
    function add_header( $headers ){
        $headers['weather'] = '天気';
        return $headers;
    }
    /**
     * コメントリストにコメントの天気を表示
     */
    function add_column( $columnName, $commentId ){
        _e( get_comment_meta( $commentId, 'weather', true ) );
    }
    /**
     * 天気メタボックスの中身を表示
     */
    function display_metabox(){
        global $comment;
        $weather = get_comment_meta( $comment->comment_ID, 'weather', true );
?>
        <select name="weather" id="weather">
            <option<?php if( $weather === '晴れ' ) _e( ' selected="selected"' ); ?>>晴れ</option>
            <option<?php if( $weather === '曇り' ) _e( ' selected="selected"' ); ?>>曇り</option>
            <option<?php if( $weather === '雨' ) _e( ' selected="selected"' ); ?>>雨</option>
        </select>
<?php
    }
    /**
     * コメント編集画面に天気メタボックスを追加
     */
    function add_metabox(){
        add_meta_box( 'weather', '天気', array( &$this, 'display_metabox' ), 'comment', 'normal' );
    }
    function comment_meta(){
        add_action( 'comment_form_logged_in_after', array( &$this, 'add_comment_element' ) );
        add_action( 'comment_form_after_fields', array( &$this, 'add_comment_element' ) );
        add_filter( 'preprocess_comment', array( &$this, 'get_weather' ) );
        add_action( 'wp_insert_comment', array( &$this, 'add_weather' ), 10, 2 );
        add_action( 'edit_comment', array( &$this, 'update_weather' ) );
        add_filter( 'manage_edit-comments_columns', array( &$this, 'add_header' ) );
        add_action( 'manage_comments_custom_column', array(&$this, 'add_column' ), 10, 2 );
        add_action( 'admin_init', array( &$this, 'add_metabox' ) );
    }
}
new comment_meta;
?>
-------------------------------------------------------