How can I add custom code snippets to my site?

Some of our documentation articles and  developer tutorials include custom code snippets you can use to change or add functionality in Restrict Content Pro. These can be added to your site in one of two ways:

Adding code to a child theme

If you have a child theme then you can add code to your theme's functions.php file. Simply add the code snippet to the bottom of the file.

If you don't have a child theme yet, you'll need to create one first. You shouldn't modify a parent theme directly because your changes will be lost when the theme is updated. For instructions on creating a child theme you can read this WordPress Codex article:  How to Create a Child Theme.

Creating a custom plugin

Creating a custom plugin is usually the better choice because it separates your extra functionality from your theme, and this way you'll keep your modification if you switch themes later.

If you're not familiar with how to create a custom plugin, you can use the free  Pluginception plugin to help you. Install Pluginception, go to Plugins > Create a New Plugin and give your plugin an appropriate name.

Then click "Create a blank plugin and activate it!" at the bottom.

Once it's created, you'll be taken to the Plugin Editor screen where you can pate your custom code snippet. The file will already have some code/information at the top - do not remove this. You want to paste your code at the very bottom, as shown below.

Once you've added your code, click "Update File" at the bottom to save.