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

Overview

Would you like to change the text that appears in the Modern Dropdown form field when there are no results found? Using a small PHP snippet you can easily change this text, you can also even make this text translatable for any multi-language site as well. In this tutorial, we’ll give you the PHP need to change this text.

Setup

To begin, you’ll need to either edit an existing form or create a new form.

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

Add a modern dropdown field to your form

By default, you’ll see this text when any visitors try to search for something in your dropdown that results in a No Results Found message.

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

Adding the PHP snippet

In order to change this text, copy and paste this PHP snippet to your site.

Single Language

/**
 * 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 ) ) {
		
        // If there are several forms on the same page, the customization will be applied to all of them.
	$config['noResultsText'] = 'Sorry, your search term was not found.';

	}

	return $config;
}

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

Multi-Lingual

/**
 * 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 ) ) {
	
        // If there are several forms on the same page, the customization will be applied to all of them.
	$config['noResultsText'] = __( 'Sorry, 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 );

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.

Filter Reference: 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 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 ) ) {
	
        // If there are several forms on the same page, the customization will be applied to all of them.
	    $config['noResultsText'] = __( 'Sorry, 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 );