Contact Form 7 drop down field include_blank value

In wordpress contact Form 7 drop down field include_blank shows value “- – -” selected by default and can be customize to some other value. For Example, if you want to show “Choose Gender” in gender dropdown instead of “- – -” use below code.

[select* gender include_blank "Male" "Female"] 

Code for functions.php.

function techstriders_replace_include_blank($name, $text, &$html) {
	$matches = false;
		preg_match('/<select name="' . $name . '"[^>]*>(.*)<\/select>/iU', $html, $matches);
	if ($matches) {
		$select = str_replace('<option value="">---</option>', '<option value="">' . $text . '</option>', $matches[0]);
		$html = preg_replace('/<select name="' . $name . '"[^>]*>(.*)<\/select>/iU', $select, $html);

function techstriders_form_elements($html) {
	techstriders_replace_include_blank('gender', 'Choose Gender', $html);
	return $html;

add_filter('wpcf7_form_elements', 'techstriders_form_elements');

Author: Muhammad Naveed

Muhammad Naveed is a Co-founder, project manager and creative Web Developer at Techstriders. He's managing all Wordpress, Woocommerce and Shopify projects.