A WordPress plugin boilerplate

The title to this snippet was a little misleading, so I changed it to clarify what this snippet actually is – it’s a plugin boilerplate template to help you get started, whether it be to create a full-blown plugin or just a selection of custom function you wish to add to your website if you do not have a child theme installed.

For this example, we are going to call the plugin My Custom Functions.

The first thing you need to do is to create a blank PHP file and name it. You can name it whatever you want. For this example, I have named it custom-functions.php. Then create a folder (dir) and name it my-custom-functions and place the PHP file inside the folder.

<?php
/*
Plugin Name: My Custom Functions
Plugin URI: https://www.yourwebsite.com
Description: Custom functions for my website
Version: 1.0
Author: Your Name
Author URI: https://www.yourwebsite.com
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: my-custom-functions
*/

if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

// Add your code below this line

You will need to change the plugin name, URI, description etc to whatever you want. Once you are happy, zip the folder and upload it via the plugins section in your WordPress website.

– LAST TESTED DECEMBER 9, 2019

Code not working? Let us know in the comments below.

Latest Snippets

Leave a comment