试图了解WordPress主题是如何构建的-奇怪的自定义帖子字段

试图了解WordPress主题是如何构建的-奇怪的自定义帖子字段,wordpress,wordpress-theming,Wordpress,Wordpress Theming,我正试图找出一个主题是如何构建的,从下面的代码中,我可以看到正在创建一个自定义的Post类型的存储 register_taxonomy( APP_TAX_STORE, array( 'promo_code','sale_offers','in_store','coupon' ), array( 'hierarchical' => true, 'labels' => array(

我正试图找出一个主题是如何构建的,从下面的代码中,我可以看到正在创建一个自定义的Post类型的存储

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\u store\u 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);
function clpr\u edit\u存储($tag,$taxonomy){
$the_store_phone=get_元数据($tag->taxonomy,$tag->term_id,'clpr_store_phone',true);
?>

看看您发布的有限代码,他们似乎已经为分类法类型创建了一个自定义元表

如果您查找该函数,它会尝试从缓存中获取元值,如果它不在缓存中,则会调用它来初始化元缓存。update_meta_cache使用一个名为_get_meta_table的函数(请参见下文,因为我只能发布两个链接)它从传递给
get\u metadata
$meta\u type
值生成一个表名,因为分类法类型不存在,它们必须创建一个自定义表并将表名添加到
$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

谢谢你的帮助,我想我对发生的事情有了进一步的了解。如果clpr_store_phone字段中有值,那么我该如何检索它们呢?我认为这一行更新了元数据($\u POST['taxonomy'],$term_id,$clpr_store_phone',$_POST['clpr_store_phone'])正在存储clpr_store_phone数据。我如何将其更改为get_metadata命令来检索它?