我试图给用户一个选项,使用类的过滤器来扩展/添加给定metabox的字段https://github.com/bainternet/My-Meta-Box
这是我的,它显示字段OKhttp://pastebin.com/mvFyyKfa
//array of options
$clients_info_array=array(
array(
\'id\' => \'client_first_name_field\',
\'type\' => \'text\',
\'options\' => array(
\'name\' => \'First Name\',
)
),
array(
\'id\' => \'client_last_name_field\',
\'type\' => \'text\',
\'options\' => array(
\'name\' => \'Last Name\',
)
),
);
$clients_info_array = apply_filters(\'clients_extra_input\',$clients_info_array);
foreach($clients_info_array as $single_client_info){
if($single_client_info[\'type\']==\'text\'){
$clients_info_metabox->addText($single_client_info[\'id\'],$single_client_info[\'options\']);
}
}
我正在尝试使用此代码添加新字段
add_filter(\'clients_extra_input\',\'custom_dog_name_field\');
function custom_dog_name_field($arr){
$arr[]= array(
\'id\' => \'client_dog_name_field_id\',
\'type\' => \'text\',
\'options\' => array(
\'name\' => \'Dog Name\',
)
);
return $arr;
}
但无论我把它放在哪里(functions.php或一个只包含该代码的新插件),我都看不到metabox上的额外字段。
我做错什么了吗?
谢谢