Codex

Function Reference/add settings field

Contents

Description

You can add new settings fields (basically, an option for wp_options database table but totally managed for you) to the existing WordPress pages using this function. Your callback function just needs to output the appropriate html input and fill it with the old value, the saving will be done behind the scenes. You can create your own sections on existing pages using add_settings_section().

NOTE: You MUST register any options you use with add_settings_field() or they won't be saved and updated automatically.

Usage

<?php add_settings_field($id$title$callback$page$section 'default'$args = array()); ?>

Parameters

  • $id (string) - String for use in the 'id' attribute of tags.
  • $title (string) - Title of the field.
  • $callback (string) - Function that fills the field with the desired inputs as part of the larger form. Name and id of the input should match the $id given to this function. The function should echo its output.
  • $page (string) - The type of settings page on which to show the field (general, reading, writing, ...).
  • $section (string) - The section of the settings page in which to show the box (default or a section you added with add_settings_section, look at the page in the source to see what the existing ones are.)
  • $args (array) - Additional arguments

Change Log

Since: 2.7.0

Source File

add_settings_field() is located in wp-admin/includes/template.php.

Related

Settings API: register_setting, unregister_setting, add_settings_field, add_settings_section

See also index of Function Reference and index of Template Tags.