WordPress 添加多个选项字段到常规设置页面
$new_general_setting = new new_general_setting();
class new_general_setting {
function new_general_setting( ) {
add_filter( 'admin_init' , array( &$this , 'register_fields' ) );
}
function register_fields() {
register_setting( 'general', 'favorite_color', 'esc_attr' );
add_settings_field('fav_color', '<label for="favorite_color">'.__('最喜欢的颜色' ).'</label>' , array(&$this, 'fields_html') , 'general' );
}
function fields_html() {
$value = get_option( 'favorite_color', '' );
echo '<input type="text" id="favorite_color" name="favorite_color" value="' . $value . '" />';
}
}
利用上述方法只能添加到一个input框,如何添加多个input框
0 个回复