26th Feb '26
/
0 comments

Searchable WordPress Timezone Dropdown

One of the minor annoyances when creating a new WordPress site is not being to search for a city name in the WordPress timezone dropdown in the general settings.

This must-use plugin fixes this.

after setting up the mu-plugin

Create a file named say, searchable-timezone-dropdown.php in your site’s wp-content/mu-plugins directory having this code:

/**
 * Plugin Name: Searchable Timezone Dropdown
 * Description: Enhances the timezone dropdown on Settings > General with Select2 search functionality.
 * Version: 1.0.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

add_action(
	'admin_enqueue_scripts',
	function ( $hook_suffix ) {
		if ( 'options-general.php' !== $hook_suffix ) {
			return;
		}

		wp_enqueue_style(
			'select2',
			'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css',
			array(),
			'4.0.13'
		);

		wp_enqueue_script(
			'select2',
			'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js',
			array( 'jquery' ),
			'4.0.13',
			true
		);

		wp_add_inline_script(
			'select2',
			"
		jQuery( document ).ready( function( $ ) {
			$( '#timezone_string' ).select2( {
				// width: '25em'
			} );
		} );
	"
		);
	}
);
Get access to all 630 Bricks code tutorials with BricksLabs Pro

Leave the first comment