You can create a simple plugin file to add in the code that you want. In your WordPress folder there is a wp-content
directory, and a plugins
directory inside that. Create a php file inside the plugins
directory, and name it something unique and descriptive; use dashes - to separate words in the name:
ben-is-neat.php
Inside the plugin file, create a comment block with some info about the plugin:
<?php
/*
Plugin Name: Ben Is Neat Plugin
Description: Ben does neat things.
Version: 0.0.1
Author: Ben
*/
There are other plugin headers that you can add to this comment block, but the "Plugin Name" is the main one; without it, WordPress will not recognize your file as a plugin.
Add the rest of your code below that comment block. If your plugin gets complex, you can move your file into it's own folder, just name the folder the same as the php file, and add other files in the same folder. Use the php include()
function to share logic between files.
Enable your plugin in the WordPress admin plugin screen.