How to Change the No Results Found Text in the Modern Dropdown Field

Would you like to customize the Modern Dropdown text that appears in the form field when no results are found? With a simple PHP snippet, you can easily change this text and even make it translatable for multi-language sites.

By default, visitors will see the No Results Found message when their search yields no results in your dropdown.

A message of No Results Found will display in the search box when the term isn't found inside the dropdown

In this tutorial, we’ll provide the PHP code you need to change this text and guide you through each step.

Creating the form

First, we’re going to create a new form and add our form fields which will include at least one Dropdown field.

Once you’ve added the Dropdown form field to your form, click on the Advanced tab and select Modern from the Style dropdown.

Add a modern dropdown field to your form

If you need help in creating a form, please review this documentation.

Changing the Modern Dropdown text

Now it’s time to add the snippet to our site.

If you need help on how and where to add snippets to your site, please check out this tutorial.

/**
 * Change the No Results Found text in Modern Dropdown.
 *
 * @link https://wpforms.com/developers/how-to-change-the-no-results-found-text-in-the-modern-dropdown-field/
 */

function wpf_dev_change_modern_dropdown_noresults_text( $config, $forms ) {
	
	// Change 1369 to an ID of your actual form.
	if ( array_key_exists( 1369, $forms ) ) {
	
	$config[ 'noResultsText' ] = __( 'Apologies, your search term was not found.', 'your-text-domain' );
	}

	return $config;
}

add_filter( 'wpforms_field_select_choicesjs_config', 'wpf_dev_change_modern_dropdown_noresults_text', 10, 2 );

This snippet will only be applied to the form ID 1369 and will change the default noResultsText message and replace it with what we’ve added.

Please remember that you’ll need to update the form ID and the personalized message for your own site.

If you need help in how to find your form ID, please review this tutorial.

And that’s all you need! Now instead of seeing No Results Found, users will see your personalized message.

Now a different message will appear when no results are found

Would you like to show all of your completed form fields inside your confirmation message? Take a look at our tutorial on How to Show All Fields in Your Confirmation Message.

Reference Filter

wpforms_field_select_choicesjs_config

FAQ

Can I also change the Press to select that appears when you hover over choices?

A: Absolutely! You can even do both with just one snippet. Use this code snippet.

/**
 * Change the hover Press to select text
 *
 * @link https://wpforms.com/developers/how-to-change-the-no-results-found-text-in-the-modern-dropdown-field/
 */

function wpf_dev_change_modern_dropdown_noresults_text( $config, $forms ) {
	
	// Change 1369 to an ID of your actual form.
	if ( array_key_exists( 1369, $forms ) ) {
	
	    $config[ 'noResultsText' ] = __( 'Apologies, your search term was not found.', 'your-text-domain' );
        $config[ 'itemSelectText' ] = __( 'Choose this option.', 'your-text-domain' );
	}

	return $config;
}

add_filter( 'wpforms_field_select_choicesjs_config', 'wpf_dev_change_modern_dropdown_noresults_text', 10, 2 );