Special Offer: Get All 151 Premium WordPress Themes for Just $99.99 $59.99 Purchase Now Learn more

How to Change the Email Subject in Your Contact Page Template

If you want to customize the subject line of the emails you receive from your website’s contact form, you can easily do so by editing the contact page template directly from your WordPress Admin Panel. This guide will walk you through the simple steps to set a hardcoded email subject.

1. Access the Theme Editor

  1. Log in to your WordPress Admin Panel.
  2. Navigate to the Left Menu and click on Appearance.
  3. From the dropdown menu, select Theme Editor.Note:

2. Locate the page-contact.php Template File

  1. On the right side of the Theme Editor, you’ll see a list of theme files.
  2. Scroll down to find the page-templates/page-contact.php file.
  3. Click on page-contact.php to open it in the editor.

3. Find the Email Sending Code

  1. In the editor, scroll down to locate the line of code that sends the email. You’re looking for a line that contains wp_mail.
  2. The code should look like this:

    wp_mail( $emailTo, __( '[Contact Form] ', 'tishonator' ).$subject, $body, $headers );

    This line sends the email with the subject line that includes [Contact Form] and the subject entered by the user.

4. Modify the Email Subject to a Hardcoded Value

  1. To set a fixed subject line for all emails from the contact form, replace the existing wp_mail line with the following code:

    wp_mail( $emailTo, 'New Contact Form Message', $body, $headers );

    Replace 'New Contact Form Message' with the exact subject line you want to use.

    Example:

    wp_mail( $emailTo, 'Website Inquiry', $body, $headers );

That’s it. Then simply save changes you made to the file.