Adding More than One Custom Settings Field
-
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 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Adding More than One Custom Settings Field’ is closed to new replies.