0

次のコードから、ストアのカスタム投稿タイプが作成されていることがわかります....

register_taxonomy( APP_TAX_STORE,
        array( 'promo_code','sale_offers','in_store','coupon' ),
        array(  'hierarchical' => true,
                'labels' => array(
                        'name' => __( 'Stores', 'appthemes'),
                        'singular_name' => __( 'Store', 'appthemes'),
                        'search_items' =>  __( 'Search Stores', 'appthemes'),
                        'all_items' => __( 'All Stores', 'appthemes'),
                        'edit_item' => __( 'Edit Store', 'appthemes'),
                        'update_item' => __( 'Update Store', 'appthemes'),
                        'add_new_item' => __( 'Add New Store', 'appthemes'),
                        'add_or_remove_items' => __( 'Add or remove Stores', 'appthemes'),
                        'separate_items_with_commas' => __( 'Separate Stores with commas', 'appthemes'),
                        'choose_from_most_used' => __( 'Choose from the most common Stores', 'appthemes'),
                        'new_item_name' => __( 'New Store Name', 'appthemes')
                ),
                'show_ui' => true,
                'query_var' => true,
                'update_count_callback' => '_update_post_term_count',
                'rewrite' => array( 'slug' => $store_tax_base_url, 'with_front' => false, 'hierarchical' => true ),
        )
);   

そのビットは理解していますが、「clpr_store_phone」というフィールドが作成されているようです....

function clpr_edit_stores($tag, $taxonomy) {
$the_store_phone = get_metadata($tag->taxonomy, $tag->term_id, 'clpr_store_phone', true);
?>

<tr class="form-field">
    <th scope="row" valign="top"><label for="clpr_phone"><?php _e('Phone Number', 'appthemes'); ?></label></th>
    <td><input type="text" name="clpr_store_phone" id="clpr_store_phone" value="<?php echo $the_store_phone; ?>"/><br /></td>
</tr>

<?php
}
add_action('stores_edit_form_fields', 'clpr_edit_stores', 10, 2);

function clpr_save_stores($term_id, $tt_id) {
if (!$term_id) return;

if(isset($_POST['clpr_store_phone']))
  update_metadata($_POST['taxonomy'], $term_id, 'clpr_store_phone',     $_POST['clpr_store_phone']);
}
add_action('edited_stores', 'clpr_save_stores', 10, 2);

これは私が混乱しているところです。ここに何が設定されていますか? 「clpr_store_phone」はタクソノミー内のカスタム フィールドですか?

誰かがそれに光を当てることができますか?

4

1 に答える 1

2

投稿した限られたコードを見ると、分類タイプのカスタム メタ テーブルが作成されているようです。

get_metadata関数を検索すると、キャッシュからメタ値を取得しようとします。そこにない場合は、update_meta_cacheを呼び出してメタ キャッシュを準備します。update_meta_cache は _get_meta_table という関数を使用します (リンクは 2 つしか投稿できないため、以下を参照)。この関数は、$meta_type渡された値からテーブル名を生成しますget_metadata。タクソノミー タイプが存在しないため、カスタム テーブルを作成してテーブル名を追加する必要があります。$wpdb

function _get_meta_table($type) {
    global $wpdb;

    $table_name = $type . 'meta';

    if ( empty($wpdb->$table_name) )
        return false;

    return $wpdb->$table_name;
}

phpxref.ftwr.co.uk/wordpress/nav.html?wp-includes/meta.php.source.html#l811

于 2012-09-20T23:10:57.730 に答える