Adding code to to your WordPress site

Throughout this Knowledge Base, you’ll find code snippets that add or modify functionality in the Mailchimp for WordPress plugin.

To use these code snippets you will need to add them to your site in a file that is loaded, like the functions.php file of your active theme.

Warning! Adding code to your site requires some technical knowledge. Adding code incorrectly can break your website.

There are various ways to go about adding code to your WordPress site.

Use a plugin

The My Custom Functions plugin allows you to add custom code snippets to your site and comes with a few nifty features over the default WordPress theme editor.

Use a child theme

If you’re using a theme that is built and supported by a third-party, it’s a good idea to use a child theme.

This will make sure that your changes will not be overwritten by theme updates.

You can read all about how to do this in the WordPress.org Codex.

When you have a child theme in place, create a file called functions.php in the child theme’s directory.

Adding code to your theme’s functions.php file

The code that you’ll find throughout our knowledge base can be copy-pasted directly into your theme its functions.php file.

Notes

If there are any details that need to be changed in the snippet before it works, we usually state this in the code snippet itself or in the article accompanying it.

Make sure you copy the entire snippet, as a missing character can lead to unexpected results.