register_setting()函数

<?php 
register_setting( 
    string $option_group, 
    string $option_name, 
    array $args = array() 
);
?>

案例

<?php
//后台设置->常规添加新的字段
function xk_general_section() {
    add_settings_section(
        'xk_settings_section', // ID
        '联系方式', // 显示在页面的标题
        'xk_settings_section_callback', // 页面回掉
        'general' // 'general', 'reading', 'writing', 'discussion', 'media'
    );

    add_settings_field(
        'address', // ID
        '地址', // 显示在页面的标题即label
        'xk_textbox_callback', // 回掉
        'general', // 'general', 'reading', 'writing', 'discussion', 'media'
        'xk_settings_section', // section ID
        array( // The $args
            'address' // Should match Option ID
        )
    );

    add_settings_field(
        'phone',
        '电话',
        'xk_textbox_callback',
        'general',
        'xk_settings_section',
        array(
            'phone'
        )
    );

    add_settings_field(
        'email',
        '邮箱',
        'xk_textbox_callback',
        'general',
        'xk_settings_section',
        array(
            'email'
        )
    );

    add_settings_field(
        'fax',
        '传真',
        'xk_textbox_callback',
        'general',
        'xk_settings_section',
        array(
            'fax'
        )
    );

    register_setting('general','address', 'esc_attr');
    register_setting('general','phone', 'esc_attr');
    register_setting('general','email', 'esc_attr');
    register_setting('general','fax', 'esc_attr');
}

function xk_settings_section_callback() {
}

function xk_textbox_callback($args) {
    $option = get_option($args[0]);
    echo '<input type="text" id="'. $args[0] .'" name="'. $args[0] .'" value="' . $option . '" />';

}
add_action( 'admin_init', 'xk_general_section' );