Check whether the string is a valid UTF-8 character, and remove all HTML tags. $str = "<h2>Title</h2>"; sanitize_text_field( $str ); // it will return "title" without any HTML tags!