WordPress at Your Fingertips

selected() WP 1.0

Outputs the html selected attribute.

Compares the first two arguments and if identical marks as selected

No Hooks.


String. HTML attribute or empty string


selected( $selected, $current, $echo );
$selected(mixed) (required)
One of the values to compare
(true) The other value to compare if not just true
Default: true
Whether to echo or just return the string
Default: true


Since 1.0.0 Introduced.

Code of selected() WP 5.8.1

function selected( $selected, $current = true, $echo = true ) {
	return __checked_selected_helper( $selected, $current, $echo, 'selected' );

form functions

No comments
    Log In