我正在尝试弄清楚主题是如何构建的,从以下代码中我可以看到正在创建自定义帖子类型的商店......
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' 是分类法中的自定义字段吗?
有人可以解释一下吗?