Using Code Snippets

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.

WPCode plugin

Note: For extra help, refer to WPCode’s guide on installing 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

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

Then, copy the custom code snippet you’d want to use from one of the WP Mail SMTP code snippet guides and paste it into the code box.

Paste PHP code in editor

Then, toggle on the Active option.

Active toggle button

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

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 for more customization options.