WordPress Remove Site Name from Email Subject

If you want to delete the site heading in the WordPress mail function “[Sitename] Forgot Password” for example. You need to add_filter the WordPress wp_mail function. We will make the function work by putting the following code in function.php page then it will filter wp_mail function for replace sitename to wordpress email subject easy and short code for wordpress

 

function.php

 

add_filter('wp_mail', 'email_subject_remove_sitename');
function email_subject_remove_sitename($email) {
    $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    $email['subject'] = str_replace("[".$blogname."] - ", "", $email['subject']);
    $email['subject'] = str_replace("[".$blogname."]", "", $email['subject']);
    return $email;
}

7 Comments

  • German Neptune


    I really can’t believe how great this site is. Keep up the good work. I’m going to tell all my friends about this place.

    reply
  • Fuss


    I don’t comment, however after reading through some of the responses on this page. I actually do have a few questions for you if you don’t mind. Could it be only me or do some of these responses look like they are written by brain dead people? 😛 And, if you are posting at other social sites, I would like to follow everything new you have to post. Could you make a list of the complete urls of all your social pages like your Facebook page, twitter feed, or linkedin profile?

    reply
  • zvodret iluret


    Thanks a lot for sharing this with all folks you really recognise what you are talking approximately! Bookmarked.

    reply

Leave a Reply

Your email address will not be published. Required fields are marked *