Where should I put code for use by Pods?

You can add code to your theme’s (or child theme’s) functions.php, use Code Snippets plugin or create your own plugin.

In some cases you may need to add a function to your website, either to hook something into the theme, or use a filter to change something in the theme or to apply one of the Code Snippets we provide to make Pods behave the way you need it to.

When working with PHP, you want to make sure you have access to your server via FTP or File Manager (through your hosting control panel). This is due to how unforgiving PHP is, if there’s an error in the code, your site can turn into a blank white page. To fix this, simply go into your server and delete the code you added.

Code Snippets

The Code Snippets plugin is a very cool way to add PHP snippets to your website. You can activate and deactivate certain snippets, and even adds notes about what they do. It has better error handling and can often not create the ‘white screen of death’ noted above.

To install it, simply go to Plugins > Add New and search for Code Snippets.

Create a Plugin

If you don’t want to use the Code Snippets plugin mentioned above, you can create your own plugin.

Usually, creating a plugin is kind of difficult, but we can actually use a plugin to make creating a plugin easier.

First, install Pluginception by going to Plugins > Add New and searching for Pluginception.

Now that it’s activated, go to Plugins > Create New Plugin.

Name it something super specific to you so it doesn’t conflict with any other plugins, and create it.

Now you can add your functions to the plugin file.

Use a Child Theme

If you’re already using a child theme, you can use the functions.php file to add your PHP.