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 paste 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.

Have more questions? Submit a request