在Wordpress-3.5.2中的自定义分类元框中添加自定义字段
无法在wordpress-3.5.2。的自定义分类元数据框中添加自定义字段。
Unable to add custom fields in custom taxonomy meta box in wordpress-3.5.2.
我已经在各种博客中检查了解决方案,但无法解决此问题。我正在使用wordpress-3.5.2
I have checked solution in various blogs but Unable to solved this problem. I am using wordpress-3.5.2
我正在尝试的是:-
// A callback function to add a custom field to our "adtag" taxonomy
add_action( 'adtag_edit_form_fields', 'adtag_callback_function', 10, 2);
// A callback function to save our extra taxonomy field(s)
add_action( 'edited_adtag', 'save_taxonomy_custom_fields', 10, 2 );
我尝试了以下链接的解决方案:-
I have tried solution from below link:-
http ://www.codehooligans.com/2010/07/07/custom-meta-for-new-taxonomies-in-wordpress-3-0/
http://sabramedia.com/blog/how-to-add-custom-fields-to-自定义分类法
http://www.wpbeginner.com/wp-tutorials/how-to-add-additional-custom-meta-fields-to-custom-分类法/
http://shibashake.com/wordpress-theme/add-term-or-taxonomy-meta-data
看看 Tax-meta-clas s 的开发目的是为分类法添加额外的字段: WordPress分类法多余字段
Take a look at the Tax-meta-class developed to add extra fields to taxonomies: WordPress Taxonomies Extra Fields the easy way
1)包括主类文件
require_once("Tax-meta-class/Tax-meta-class.php");
2)配置分类法自定义字段
$config = array(
'id' => 'demo_meta_box',
'title' => 'Demo Meta Box',
'pages' => array('category'),
'context' => 'normal',
'fields' => array(),
'local_images' => false,
'use_with_theme' => false
);
3)初始化分类自定义字段
$my_meta = new Tax_Meta_Class($config);
4)添加字段
//text field
$my_meta->addText('text_field_id',array('name'=> 'My Text '));
//textarea field
$my_meta->addTextarea('textarea_field_id',array('name'=> 'My Textarea '));
5)完成分类法多余的字段减速[重要!]
$my_meta->Finish();
6)获取保存的数据
$saved_data = get_tax_meta($term_id,'text_field_id');
echo $saved_data;