How to create custom email templates for SliceWP

One little thing that could go a long way in running a successful affiliate program is making sure your messaging aligns with your brand image and how you want to be perceived.

It’s important that you are able to customize these email notifications to match your branding and messaging. You know, to really make them yours and easily recognizable for your affiliate partners.

In SliceWP we tried our best to create a simple, yet powerful email system, with which you can:

  • notify both administrators and your affiliate partners;
  • customize each notification separately (there are six different ones);
  • add merge tags to your emails to make them as personal as possible.

We’ve even added a templating mechanism through which you can include your own custom built email templates.

Today, I’m going to run you through understanding what an email template is in SliceWP, how you can create one and how your affiliate program can benefit from it.

What is an email template?

Within SliceWP, an email template is a simple PHP file, that contains all the HTML and CSS required to style the email.

Because notification emails for an affiliate program are quite simple, compared to newsletters for example, we’ve tried to reduce the code for the templates as much as possible.

Even so, the files are quite long. Don’t get discouraged though, because the code is quite simple and most of it you won’t even need to touch. There are just two main aspects to it, the HTML part and the CSS part.

For instance, here’s a complete template file:


The below code represents the important HTML of the entire file. It has a logo section, a main content section and a footer section.

For customization purposes, the only area you may want to modify is the footer section. This is a great spot to add your business’ address, a thing we highly recommend, as it can boost the credibility of your affiliate program.

You can leave the logo and main sections untouched. They are populated with the content you add in SliceWP’s email notification settings.


The CSS part can look quite dramatic. It has much more code compared to the HTML part. Most of it, however, is used just to reset the styles of the email. You’ll probably only modify a few values to reach the needed design.

For example, the following four templates (that you can get for free below) were ready in about 10 minutes, just by altering the colors for the background, text, button and the border of the button.

Adding a template to SliceWP

You can add email template files to your WordPress website two ways: through your theme or through a custom built plugin.

Templates in themes

If you already have a child theme active, we recommend going the theme way, as it’s quicker.

To start, create a new folder within your theme and name it “slicewp-email-templates”. In it place the template files.

Then, to make sure SliceWP recognizes these templates, add at the beginning of each file a PHP comment similar to the one below:

“My Custom Email Template” is the name of this example template, but you can change it to whatever you like. Go crazy!

To finish, save the file and navigate to SliceWP’s email notification settings in your WordPress admin area. The template should be right there, ready for use.

custom template selection in affiliates program management plugin
Templates in custom built plugins

If you prefer keeping your themes as clean as possible or just like organizing your custom code in plugins, there’s also a more technical way of adding email templates.

You can write a callback function for SliceWP’s “slicewp_register_email_templates” filter where you can include multiple templates at once, similar to the one below:

There are three things to take into account here:

  • the slug – This is “my_custom_email_template” in the above example. Make sure no other email template is using it, or you will overwrite it.
  • the name – This is the text that will appear in the drop-down settings field.
  • the path – This is the server path of the file, which tells SliceWP where to look for the template.

By registering the template files through the filter you won’t need to include the opening PHP comment, the one mandatory for themes.

Testing your email templates

SliceWP offers a couple of ways for testing the email templates: preview them in browser and/ or send a test email.

You can find both options under the email customization tags in SliceWP’s settings page.

email notification meta tags for affiliate program

The preview option will open a new tab directly in the browser. This option is great if you want to quickly check the look and feel of the email.

However, the actual email might look differently when viewed in an email provider.

Even today, doing email properly is hard. Providers processes emails in their own way, so we strongly recommend you to send test emails and double check your designs before enabling them for your affiliates.

Get started with custom email templates right away

To make it easy for you to start branding your email notifications, we’ve put together a small helper plugin.

It contains only five files, four of which being the template files for the designs we presented earlier. Use them as they are, modify them to your liking or remove any of the ones you don’t need. It’s all up to you.

To download the plugin, just click on this link.

After you download the .zip file, upload it from your WordPress admin area -> Plugins -> Add New -> Upload Plugin.

Once active, you should see the four options in SliceWP -> Settings -> Email Notifications, as shown below:

custom template selection in affiliates program management plugin

We really hope you find this tutorial helpful. If you feel like essential information is missing from it, please let us know either on Twitter or through email. Our inboxes are always open.