add_screen_option( string $option, mixed $args = array() )

Register and configure an admin screen option

Parameters

$optionstringrequired
An option name.
$argsmixedoptional
Option-dependent arguments.

Default:array()

Source

function add_screen_option( $option, $args = array() ) {
	$current_screen = get_current_screen();

	if ( ! $current_screen ) {
		return;
	}

	$current_screen->add_option( $option, $args );
}

Changelog

VersionDescription
3.1.0Introduced.

User Contributed Notes

  1. Skip to note 3 content

    The $option parameter define the object (input or radio button) which will be printed to the screen option section.

    add_screen_option only accept 2 methods:

    • 1. ‘per_page’
    • 2. ‘layout_columns’

    Example 1:

    add_screen_option( 'per_page', array( 'label' => 'My Label', 'default' => 1, 'option' => 'option_name' ) );

    will print

    <input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]" id="option_name" maxlength="3" value="1">

    Example 2:

    add_screen_option( 'layout_columns', array( 'max' => 2, 'default' => 2 ) );

    will print

    <input type="radio" name="screen_columns" value="1">
    <input type="radio" name="screen_columns" value="2" checked="checked">

    add_screen_option not support the checkboxes method yet.

You must log in before being able to contribute a note or feedback.