Adding Code to Your Site When You’re Not a “Coder”

It’s not uncommon for customers of ours to want to change the appearance or behavior of their event calendars. Our support staff is not able to help with customizations, though, and so the responsibility of writing custom code often falls squarely and solely on the shoulders of the customer.

The problem is that most customers of ours aren’t programmers, developers, or otherwise familiar with writing code. Even in a situation where our support team does go “above and beyond” and supplies a code snippet, the customer might still not know how to get that code onto their site in the first place.

There are three main workarounds that even the most code-averse folks can take advantage of to get custom code onto their sites.

In this Post

Method One: Writing a Custom Plugin

Writing a WordPress plugin might seem tricky, but the level of difficulty and complexity really just depends on what you’re trying to do. Are you trying to recreate The Events Calendar from scratch? Well, this would certainly be a very complicated plugin to make.

But if you’re just trying to add a few snippets to your site, writing a plugin is simple and can be boiled down to just the following few steps.

Step #1
First, make a .php file on your computer. Not sure how to make a .php file? A quick search online will reveal how easy it is.

Step #2
Next, add an opening PHP tag and a WordPress plugin header to the top this file. An “opening PHP tag” looks like this: <?php

After that tag, write a plugin header. A plugin header is just some basic information about the plugin: its name, its author, etc. Here is an example you could copy and paste—just replace things like the plugin name, author name, etc., to match your own project:

Plugin Name: Snippet — Move the Attendees List to Top of Posts
Plugin URI:
Description: This is my quick snippet to move the attendees lists from the bottom of posts to the top.
Version: 1.0.0
Author: George
Author URI:
License: GPLv2 or later

Step #3
You can now add your custom code to the .php file. Whether you are writing your own code or just copying-and-pasting code from a support team member or something, you would just place the code below the plugin header. Check out this Gist for a real example file—note how the PHP tag is at the top of the file, then the plugin header below that, and then the actual snippet of code is below the header.

Step #4
Save the completed file on your computer, and then compress a copy of the file into a .zip. Not sure how to do this? Again, a quick search online will reveal numerous (simple) ways of doing it.

Step #5
Once you have your plugin file saved as a .zip on your computer, head to Plugins → Add New → Upload in your site’s wp-admin. Once here, upload the .zip you created in Step #4.

Upon completion of the upload, you can then activate the plugin like any other plugin and the code will run on your site.

Method Two: Using the Appearance Editor

There is a simpler alternative to creating a plugin: adding custom code to your theme’s functions.php file via the Appearance → Editor screen in your wp-admin.

While this method is simpler, it’s not without a significant downside: the changes to functions.php you make will be overwritten upon each theme update. So you would have to manually add the customizations back after every time you update your theme.

To take advantage of the Appearance → Editor method, simply head to the Appearance → Editor page in your wp-admin and navigate to your theme’s functions.php file. Then write or copy-and-paste the code snippet you want to add to your site.

Here is a screenshot showing the same snippet from Method One, but pasted into the theme functions.php file in Appearance → Editor:

Screen Shot 2016-08-29 at 4.08.18 PM

Method Three: Using a “Custom Function” Plugin

This last method is perhaps the simplest of all: All you have to do for this third method is search for a plugin on that lets you add custom code snippets directly on your site.

Using a plugin that provides this functionality is a great way to go about adding snippets for the following reasons:

  • Using a plugin means that any code you add will not be tied to the site’s theme—so you won’t have to add the code back after each theme update like in the second method above.
  • It’s a great way to save time compared to the first method above, in which you create your own plugin to do the job.
  • You get to add code from right within your site’s wp-admin!

There are numerous plugins out there that let you add custom code snippets. Your best course of action is to search the plugins repository for a plugin you particularly like. Here are some recommendations from our support team:

There is no “right” method for adding custom code snippets to your WordPress site. Each site and project has different needs and constraints, so evaluate the various options described above and use whichever method best applies.

Keep in mind that you can also, of course, use the methods above in conjunction with each other. For example: Maybe you use the second method to quickly test out a few different snippets—you add them in the Appearance → Editor screen quickly just to see which snippet is the most effective. Once you find the right snippet, you then take the extra bit of time to make a plugin out of it as per the first method above for a more stable, long-term solution.

If a customization job blooms in scope and you need some help from professionals—or just otherwise want to call in the help of a pro—check out our customizations overview page.

And please, before you make any customizations, make a backup of your site!