Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

lwynne on "Adding More than One Custom Settings Field"

$
0
0

I am using the code below to add an extra field in my settings. I am attempting to add a second field (while keeping the first) and I'm unsure what the proper way to do so is. Any help?

add_filter('admin_init', 'my_general_settings_register_fields');

function my_general_settings_register_fields()
{
    register_setting('general', 'my_field', 'esc_attr');
    add_settings_field('my_field', '<label for="my_field">'.__('My Field' , 'my_field' ).'</label>' , 'my_general_settings_fields_html', 'general');

}

function my_general_settings_fields_html()
{
    $value = get_option( 'my_field', '' );
    echo '<input type="text" id="my_field" name="my_field" value="' . $value . '" />';
}

Viewing all articles
Browse latest Browse all 8245

Trending Articles