function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array() {}

Add a new field to a section of a settings page
Part of the Settings API. Use this to define a settings field that will show as part of a settings section inside a settings page. The fields are shown using do_settings_fields() in do_settings-sections()


  • string $id: Slug-name to identify the field. Used in the ‘id’ attribute of tags.
  • string $title: Formatted title of the field. Shown as the label for the field during output.
  • string $callback: Function that fills the field with the desired form inputs. The function should echo its output.
  • string $page: The slug-name of the settings page on which to show the section (general, reading, writing, …).
  • string $section: The slug-name of the section of the settings page in which to show the box (default, …).
  • array $args: Additional arguments

Source code

function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {

	global $wp_settings_fields;

	if ( 'misc' == $page ) {

		_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );

		$page = 'general';


	if ( !isset($wp_settings_fields) )

		$wp_settings_fields = array();

	if ( !isset($wp_settings_fields[$page]) )

		$wp_settings_fields[$page] = array();

	if ( !isset($wp_settings_fields[$page][$section]) )

		$wp_settings_fields[$page][$section] = array();

	$wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: