Search: Changing the default option in a select (drop down) field

By default, the first option of a drop-down field (also called a "select") on a search bar is a dash "—". 

We can change that to a more intuitive text like "-- Select --" by using this code below:

 * Modify the text for the default option in a select (multi or single dropdown)
 * @param string $default_option Default: `—` (—)
 * @param string $field_type Field type: "select" or "multiselect"
 * @return string
add_filter( 'gravityview/extension/search/select_default', function( $default, $select_type = 'select' ) {

	if( 'select' === $select_type ) {
		return '-- Select --';
	return '-- Select One or More --';
}, 10, 2 );

Read here how to add these code samples to your website: Where to put code samples.

Here's how it'll look now:

The same code snippet works for Multi Select fields:

Screenshot of a Multi Select field on a Search Bar

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us