这是我的代码:
$config = array(
\'id\' => \'tax_meta_box\', // meta box id, unique per meta box
\'title\' => \'Tax Meta Box\', // meta box title
\'pages\' => array(\'category\'), // taxonomy name, accept categories, post_tag and custom taxonomies
\'context\' => \'normal\', // where the meta box appear: normal (default), advanced, side; optional
\'fields\' => array(), // list of meta fields (can be added by field arrays)
\'local_images\' => false, // Use local or hosted images (meta box images for add/remove)
\'use_with_theme\' => get_template_directory_uri() . \'/Tax-Meta-Class/Tax-meta-class\'
);
/*
* Initiate your meta box
*/
$my_meta = new Tax_Meta_Class($config);
//Image field
$my_meta->addImage(\'image_field\',array(\'name\'=> __(\'My Image \',\'tax-meta\')));
$my_meta->Finish();
//这是我主页上的一行
<?php $terms = get_terms( \'category\' );
foreach($terms as $p_cat):
$term_id = $p_cat->term_id;
$saved_data = get_tax_meta($term_id,\'image_field\',true);
echo \'<pre>\';
echo $term_id; // Echoes \'1\' which is the category ID
echo $saved_data; // Doesn\'t show anything . Wonder Why!!
exit;
?>
不仅仅是图像,我无法让它显示其他文本字段等。。我做错了什么?