### [Using Code Snippets](https://wpmailsmtp.com/docs/using-code-snippets/)

**Published:** November 21, 2023
**Author:** Umair Majeed

**Excerpt:** Learn how to add code snippets safely using the WPCode plugin.

**Content:**

Would you like to learn about an easy way to add custom code snippets to your WordPress website? WPCode plugin lets you add code snippets without the hassle of editing your theme’s function.php file.

In this guide, you’ll learn how to install and use the WPCode plugin to add custom PHP code snippets from WP Mail SMTP.

### Getting Started with WPCode

To get started, you’ll need to install and activate the official [WPCode plugin for WordPress](https://wordpress.org/plugins/insert-headers-and-footers/ "WordPress.org: AMP").

![WPCode plugin](https://wpmailsmtp.com/wp-content/uploads/2023/07/wpcode-plugin.png "WPCode plugin")

 **Note:** For extra help, refer to WPCode’s guide on [installing the WPCode plugin](https://wpcode.com/docs/how-to-install-the-wpcode-plugin/).

### Adding Custom PHP Code Snippets

Once you’ve installed the plugin, click on **Code Snippets** **»** **+ Add New** in your WordPress sidebar menu.

Then, hover over **Add Your Custom Code (New Snippet)** and click on the **Use snippet** button.

![Custom code Use snippet button](https://wpmailsmtp.com/wp-content/uploads/2023/07/add-your-custom-code-snippet-3-2.png "Use snippet button")

This opens up the code editor for your custom code snippet. Start by naming your custom code snippet with a title that you’ll easily remember. This will help you know which code it is, at a glance.

Next, select **PHP Snippet** from the **Code Type** dropdown.

![Select PHP from Code Type dropdown](https://wpmailsmtp.com/wp-content/uploads/2023/07/code-type-dropdown.png "Code Type dropdown")

Then, copy the custom code snippet you’d want to use from one of the [WP Mail SMTP code snippet guides](https://wpmailsmtp.com/categories/docs/code-snippets/) and paste it into the code box.

![Paste PHP code in editor](https://wpmailsmtp.com/wp-content/uploads/2023/07/php-code-snippet.png)

Then, toggle on the **Active** option.

![Active toggle button](https://wpmailsmtp.com/wp-content/uploads/2023/07/active-toggle-button.png)

Next, you’ll see some options in the **Insertion** section. You can skip this, as we’re dealing with a PHP snippet, the **Auto Insert** method will be used by default, allowing it to run everywhere on your site. So there’s no need to change anything in this section.

Once you’ve done all the changes, click on the **Save Snippet** button.

![Save Snippet button](https://wpmailsmtp.com/wp-content/uploads/2023/07/save-snippet-button.png "Save Snippet button")

After you’ve activated and saved the code snippet, it will be added to your site automatically.

That’s it! Now you know how to successfully add a custom PHP code snippet to your WordPress site.

Next, want to explore more ways to customize your WP Mail SMTP setup? Be sure to take a look at our [code snippets tutorials](https://wpmailsmtp.com/categories/docs/code-snippets/ "WP Mail SMPT Code Snippets") for more customization options.

**Categories:** Code Snippets

---

