Title: wp_dropdown_languages
Published: September 4, 2014
Last modified: August 20, 2026

---

# wp_dropdown_languages( string|array $args = array() ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#wp--skip-link--target)

Displays or returns a Language selector.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#see-also)󠁿

 * [get_available_languages()](https://developer.wordpress.org/reference/functions/get_available_languages/)
 * [wp_get_available_translations()](https://developer.wordpress.org/reference/functions/wp_get_available_translations/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#parameters)󠁿

 `$args`string|arrayoptional

Array or string of arguments for outputting the language selector.

 * `id` string
 * ID attribute of the select element. Default `'locale'`.
 * `name` string
 * Name attribute of the select element. Default `'locale'`.
 * `languages` string[]
 * List of installed languages, contain only the locales.
 * `translations` array
 * List of available translations. Default result of [wp_get_available_translations()](https://developer.wordpress.org/reference/functions/wp_get_available_translations/).
 * `selected` string
 * Language which should be selected.
 * `echo` bool|int
 * Whether to echo the generated markup. Accepts 0, 1, or their boolean equivalents.
   Default 1.
 * `show_available_translations` bool
 * Whether to show available translations. Default true.
 * `show_option_site_default` bool
 * Whether to show an option to fall back to the site’s locale. Default false.
 * `show_option_en_us` bool
 * Whether to show an option for English (United States). Default true.
 * `explicit_option_en_us` bool
 * Whether the English (United States) option uses an explicit value of en_US instead
   of an empty value. Default false.

Default:`array()`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#return)󠁿

 string HTML dropdown list of languages.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#source)󠁿

    ```php
    function wp_dropdown_languages( $args = array() ) {

    	$parsed_args = wp_parse_args(
    		$args,
    		array(
    			'id'                          => 'locale',
    			'name'                        => 'locale',
    			'languages'                   => array(),
    			'translations'                => array(),
    			'selected'                    => '',
    			'echo'                        => 1,
    			'show_available_translations' => true,
    			'show_option_site_default'    => false,
    			'show_option_en_us'           => true,
    			'explicit_option_en_us'       => false,
    		)
    	);

    	// Bail if no ID or no name.
    	if ( ! $parsed_args['id'] || ! $parsed_args['name'] ) {
    		return;
    	}

    	// English (United States) uses an empty string for the value attribute.
    	if ( 'en_US' === $parsed_args['selected'] && ! $parsed_args['explicit_option_en_us'] ) {
    		$parsed_args['selected'] = '';
    	}

    	$translations = $parsed_args['translations'];
    	if ( empty( $translations ) ) {
    		require_once ABSPATH . 'wp-admin/includes/translation-install.php';
    		$translations = wp_get_available_translations();
    	}

    	/*
    	 * $parsed_args['languages'] should only contain the locales. Find the locale in
    	 * $translations to get the native name. Fall back to locale.
    	 */
    	$languages = array();
    	foreach ( $parsed_args['languages'] as $locale ) {
    		if ( isset( $translations[ $locale ] ) ) {
    			$translation = $translations[ $locale ];
    			$languages[] = array(
    				'language'    => $translation['language'],
    				'native_name' => $translation['native_name'],
    				'lang'        => current( $translation['iso'] ),
    			);

    			// Remove installed language from available translations.
    			unset( $translations[ $locale ] );
    		} else {
    			$languages[] = array(
    				'language'    => $locale,
    				'native_name' => $locale,
    				'lang'        => '',
    			);
    		}
    	}

    	$translations_available = ( ! empty( $translations ) && $parsed_args['show_available_translations'] );

    	// Holds the HTML markup.
    	$structure = array();

    	// List installed languages.
    	if ( $translations_available ) {
    		$structure[] = '<optgroup label="' . esc_attr_x( 'Installed', 'translations' ) . '">';
    	}

    	// Site default.
    	if ( $parsed_args['show_option_site_default'] ) {
    		$structure[] = sprintf(
    			'<option value="site-default" data-installed="1"%s>%s</option>',
    			selected( 'site-default', $parsed_args['selected'], false ),
    			_x( 'Site Default', 'default site language' )
    		);
    	}

    	if ( $parsed_args['show_option_en_us'] ) {
    		$value       = ( $parsed_args['explicit_option_en_us'] ) ? 'en_US' : '';
    		$structure[] = sprintf(
    			'<option value="%s" lang="en" data-installed="1"%s>English (United States)</option>',
    			esc_attr( $value ),
    			selected( '', $parsed_args['selected'], false )
    		);
    	}

    	// List installed languages.
    	foreach ( $languages as $language ) {
    		$structure[] = sprintf(
    			'<option value="%s" lang="%s"%s data-installed="1">%s</option>',
    			esc_attr( $language['language'] ),
    			esc_attr( $language['lang'] ),
    			selected( $language['language'], $parsed_args['selected'], false ),
    			esc_html( $language['native_name'] )
    		);
    	}
    	if ( $translations_available ) {
    		$structure[] = '</optgroup>';
    	}

    	// List available translations.
    	if ( $translations_available ) {
    		$structure[] = '<optgroup label="' . esc_attr_x( 'Available', 'translations' ) . '">';
    		foreach ( $translations as $translation ) {
    			$structure[] = sprintf(
    				'<option value="%s" lang="%s"%s>%s</option>',
    				esc_attr( $translation['language'] ),
    				esc_attr( current( $translation['iso'] ) ),
    				selected( $translation['language'], $parsed_args['selected'], false ),
    				esc_html( $translation['native_name'] )
    			);
    		}
    		$structure[] = '</optgroup>';
    	}

    	// Combine the output string.
    	$output  = sprintf( '<select name="%s" id="%s">', esc_attr( $parsed_args['name'] ), esc_attr( $parsed_args['id'] ) );
    	$output .= implode( "\n", $structure );
    	$output .= '</select>';

    	if ( $parsed_args['echo'] ) {
    		echo $output;
    	}

    	return $output;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/l10n.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/l10n.php#L1740)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/l10n.php#L1740-L1866)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_get_available_translations()](https://developer.wordpress.org/reference/functions/wp_get_available_translations/)`wp-admin/includes/translation-install.php` |

Get available translations from the WordPress.org API.

  | 
| [esc_attr_x()](https://developer.wordpress.org/reference/functions/esc_attr_x/)`wp-includes/l10n.php` |

Translates string with gettext context, and escapes it for safe use in an attribute.

  | 
| [selected()](https://developer.wordpress.org/reference/functions/selected/)`wp-includes/general-template.php` |

Outputs the HTML selected attribute.

  | 
| [_x()](https://developer.wordpress.org/reference/functions/_x/)`wp-includes/l10n.php` |

Retrieves translated string with gettext context.

  | 
| [esc_attr()](https://developer.wordpress.org/reference/functions/esc_attr/)`wp-includes/formatting.php` |

Escaping for HTML attributes.

  | 
| [esc_html()](https://developer.wordpress.org/reference/functions/esc_html/)`wp-includes/formatting.php` |

Escaping for HTML blocks.

  | 
| [wp_parse_args()](https://developer.wordpress.org/reference/functions/wp_parse_args/)`wp-includes/functions.php` |

Merges user defined arguments into defaults array.

  |

[Show 4 more](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#)

| Used by | Description | 
| [login_footer()](https://developer.wordpress.org/reference/functions/login_footer/)`wp-login.php` |

Outputs the footer for the login page.

  | 
| [show_blog_form()](https://developer.wordpress.org/reference/functions/show_blog_form/)`wp-signup.php` |

Generates and displays the Sign-up and Create Site forms.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_dropdown_languages/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.0/) | Introduced the `explicit_option_en_us` argument. | 
| [5.1.0](https://developer.wordpress.org/reference/since/5.1.0/) | Introduced the `show_option_en_us` argument. | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | Introduced the `show_option_site_default` argument. | 
| [4.3.0](https://developer.wordpress.org/reference/since/4.3.0/) | Introduced the `echo` argument. | 
| [4.0.0](https://developer.wordpress.org/reference/since/4.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_dropdown_languages%2F)
before being able to contribute a note or feedback.