Using WordPress ‘phone_content’ PHP filter

The phone_content WordPress PHP filter allows you to modify the content of a post submitted by email before it’s saved to the database.


add_filter('phone_content', 'my_custom_phone_content');

function my_custom_phone_content($content) {
  // your custom code here
  return $content;


  • $content (string) – The email content to be filtered.

More information

See WordPress Developer Resources: phone_content


Remove HTML tags from email content

Strip out any HTML tags from the email content before saving the post.

add_filter('phone_content', 'strip_html_tags_from_email_content');

function strip_html_tags_from_email_content($content) {
  $content = strip_tags($content);
  return $content;

Add a custom prefix to the email content

Add a prefix to the email content, like “Email Post: “.

add_filter('phone_content', 'add_custom_prefix_to_email_content');

function add_custom_prefix_to_email_content($content) {
  $content = 'Email Post: ' . $content;
  return $content;

Convert email content to uppercase

Change the entire email content to uppercase before saving.

add_filter('phone_content', 'convert_email_content_to_uppercase');

function convert_email_content_to_uppercase($content) {
  $content = strtoupper($content);
  return $content;

Replace specific words in email content

Replace the word “WordPress” with “Awesome CMS” in the email content.

add_filter('phone_content', 'replace_word_in_email_content');

function replace_word_in_email_content($content) {
  $content = str_replace('WordPress', 'Awesome CMS', $content);
  return $content;

Append a custom footer to the email content before saving.

add_filter('phone_content', 'add_custom_footer_to_email_content');

function add_custom_footer_to_email_content($content) {
  $footer = "\n\n--\nThis post was submitted via email.";
  $content .= $footer;
  return $content;