我想了解如何構建一個主題,從下面的代碼中我可以看到正在創建一個自定義發佈類型的商店.. ..試圖瞭解如何構建一個WordPress主題 - 奇怪的自定義發佈字段
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'是分類中的自定義字段嗎?
有人可以解釋一下嗎?
感謝,我想我是再沿瞭解正在發生的事情。如果在clpr_store_phone字段中有值,那麼我將如何去檢索它們? – fightstarr20
你可以像使用'get_metadata'一樣使用 – ninnypants
我認爲這行update_metadata($ _ POST ['taxonomy'],$ term_id,'clpr_store_phone',$ _POST ['clpr_store_phone']);正在存儲clpr_store_phone數據。我將如何將其更改爲get_metadata命令來檢索它? – fightstarr20