3 Ways to Add Code Customizations to Your Site
One of the key benefits of using Charitable is that it provides many ways in which you can customize.
We manage a growing library of code snippets at https://github.com/Charitable/library which show different ways that you can tailor Charitable to your needs.
But if you want to add a bit of code to your site, how should you do it? There are several ways to do this.
Option 1: Create a custom plugin
Now, this probably sounds quite hard, but it is easier than you think! As long as you have FTP access to your website, this solution is the most efficient way to add custom code to your site.
Here’s how to create a custom plugin in three steps:
- Create a folder called
- Inside this plugin, create a new file called
- At the top of this file, paste the following:
/** * Plugin Name: My Custom Code * Description: A plugin with all my custom code. * Version: 1.0.0 * Author: Your Name * Author URI: https://yourwebsite.com/ */
my-custom-code folder to your
wp-content/plugins folder via FTP, then navigate to the Plugins page in your WordPress dashboard and you should see your “My Custom Code” plugin listed there. Activate it.
You now have a custom plugin that you can drop code snippets into directly. The benefit of this approach is that it will work with any theme, and it gives you the maximum amount of control over what you are doing.
Option 2: Use the Code Snippets plugin
If you don’t like the idea of creating your own plugin, the next best approach is to use a plugin called Code Snippets.
Search for Code Snippets with the search field in Plugins > Add New, then install and activate it.
Now, when you have a new bit of code to add, simply go to Snippets > Add Snippet in your WordPress dashboard and paste in your code. Be sure to Activate the code snippet too, or it won’t have any effect.
Option 3: Use your child theme’s functions.php file
If you are using a child theme, you can add code snippets directly to its
functions.php file. While you could also add this to a regular theme’s
functions.php file, the risk with this approach is that you will lose your customizations when you update to a new version of the theme.