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

Introduction

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.

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

In this tutorial, we’ll give you the PHP needed to change this text and walk 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.

Adding the PHP snippet

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 ) ) {
	
        // If there are several forms on the same page, the customization will be applied to all of them.
	$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.

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 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 ) ) {
	
        // If there are several forms on the same page, the customization will be applied to all of them.
	    $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 );