21Nov

WordPress Contact Form 7 edit “-Please choose an option-” copy of include_blank

Here is how to replace the include_blank default text “-Please choose an option-” that is generated when you use the include_blank option in your select. In functions.php you can add a filter to update it.

Edit the Placeholder Text of include_blank in a Contact Form 7 dropdown menu

Add a filter to your theme’s functions.php file

function my_wpcf7_form_elements($html) {
    $text_to_replace = '—Please choose an option—'; 
    $new_text = '- Select -';
    $html = str_replace($text_to_replace, $new_text, $html);
    return $html;
}
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements');

Be careful with the specific dash character used in the default text, it needs to be coded as — otherwise it won’t recognise the special character.

Subscribe
Notify of
0 Comments
Oldest
Newest
Inline Feedbacks
View all comments