On this page
selected( mixed $selected, mixed $current = true, bool $echo = true ): string
Outputs the HTML selected attribute.
Description
Compares the first two arguments and if identical marks as selected.
Parameters
$selectedmixed Required-
One of the values to compare.
$currentmixed Optional-
The other value to compare if not just true.
Default:
true $echobool Optional-
Whether to echo or just return the string.
Default:
true
Return
string HTML attribute or empty string.
Source
File: wp-includes/general-template.php. View all references
function selected( $selected, $current = true, $echo = true ) {
return __checked_selected_helper( $selected, $current, $echo, 'selected' );
}
Related
Uses
| Uses | Description |
|---|---|
| __checked_selected_helper() wp-includes/general-template.php | Private helper function for checked, selected, disabled and readonly. |
Used By
| Used By | Description |
|---|---|
| WP_Comments_List_Table::comment_type_dropdown() wp-admin/includes/class-wp-comments-list-table.php | Displays a comment type drop-down for filtering on the Comments list table. |
| WP_Posts_List_Table::formats_dropdown() wp-admin/includes/class-wp-posts-list-table.php | Displays a formats drop-down for filtering items. |
| WP_Customize_Nav_Menu_Location_Control::render_content() wp-includes/customize/class-wp-customize-nav-menu-location-control.php | Render content just like a normal select control. |
| wp_dropdown_languages() wp-includes/l10n.php | Displays or returns a Language selector. |
| install_theme_search_form() wp-admin/includes/theme-install.php | Displays search form for searching themes. |
| WP_List_Table::months_dropdown() wp-admin/includes/class-wp-list-table.php | Displays a dropdown for filtering items in the list table by month. |
| mu_dropdown_languages() wp-admin/includes/ms.php | Generates and displays a drop-down of available languages. |
| choose_primary_blog() wp-admin/includes/ms.php | Handles the display of choosing a user’s primary site. |
| install_search_form() wp-admin/includes/plugin-install.php | Displays a search form for searching plugins. |
| touch_time() wp-admin/includes/template.php | Prints out HTML form date elements for editing post or comment publish date. |
| page_template_dropdown() wp-admin/includes/template.php | Prints out option HTML elements for the page templates drop-down. |
| parent_dropdown() wp-admin/includes/template.php | Prints out option HTML elements for the page parents drop-down. |
| media_upload_library_form() wp-admin/includes/media.php | Outputs the legacy media upload form for the media library. |
| post_submit_meta_box() wp-admin/includes/meta-boxes.php | Displays post submit form fields. |
| WP_Media_List_Table::get_views() wp-admin/includes/class-wp-media-list-table.php | |
| Custom_Background::admin_page() wp-admin/includes/class-custom-background.php | Displays the custom background page. |
| wp_dropdown_categories() wp-includes/category-template.php | Displays or retrieves the HTML dropdown list of categories. |
| WP_Nav_Menu_Widget::form() wp-includes/widgets/class-wp-nav-menu-widget.php | Outputs the settings form for the Navigation Menu widget. |
| WP_Widget_Tag_Cloud::form() wp-includes/widgets/class-wp-widget-tag-cloud.php | Outputs the Tag Cloud widget settings form. |
| WP_Widget_Links::form() wp-includes/widgets/class-wp-widget-links.php | Outputs the settings form for the Links widget. |
| WP_Widget_Pages::form() wp-includes/widgets/class-wp-widget-pages.php | Outputs the settings form for the Pages widget. |
| wp_widget_rss_form() wp-includes/widgets.php | Display RSS widget options form. |
| wp_dropdown_users() wp-includes/user.php | Creates dropdown HTML content of users. |
| WP_Customize_Control::render_content() wp-includes/class-wp-customize-control.php | Render the control’s content. |
| wp_print_media_templates() wp-includes/media-template.php | Prints the templates used in the media manager. |
Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/selected