• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP Bitz

A curated collection of code snippets for WordPress

  • Home
  • About
  • Blog
  • Code Snippets
You are here: Home / WordPress Development Tips / How to Create a Site Specific Plugin

How to Create a Site Specific Plugin

WordPress Development Tips · December 4, 2019

This post brought to you by RocketGeek, ButlerBlog, and the following:

 

A common question I get when supporting WordPress users is “where to I put this custom code snippet.”

A frequent and simple answer to that question is, “In your theme’s functions.php file.”

While that’s not necessarily a wrong answer, it’s not the best answer. Putting custom code snippets in your theme’s functions.php means that if you change themes, you have to migrate all that code.

A much simpler solution is to create a site specific plugin to store your custom code. That way, all of your customizations stay with you.

But how do you do that?

I have a simple site specific plugin framework available on github that you can use for any and all of your custom code snippets. You can use it as-is, or you can add additional files if you want to separate custom code by different groupings (such as customizations for multiple plugins). You could also copy and rename the plugin to create separate plugins within a single site.

How to get started

To get started, copy the entire package from github. Rename files as needed.

The core file structure consists of the following:

|– site-specific-plugin.php – The plugin initialization file.
|– readme.txt – A standard WP plugin readme file.
|– license – The GPL license.
|– custom/
|– functions.php – A file to contain your custom PHP functions.
|– custom.js – A file to contain your custom JS.
|– style.css – A file to contain your custom CSS.

Install the folder as you would a regular plugin. Once activated, you can edit locally and upload changes via FTP or you can edit using the WordPress plugin editor. Use caution if editing live on the site – if you make a code error, this could crash your site.

Filed Under: WordPress Development Tips

Chad Butler

This post brought to you by RocketGeek, ButlerBlog, and the following:

 

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Join for free!

Get free code snippets, WordPress best practices, and practical Content Marketing advice from seasoned WordPress expert Chad Butler (butlerblog):

Recent Posts

  • Notice: Function WP_Block_Patterns_Registry::register was called incorrectly
  • Use WP-CLI to back up your site
  • Bitnami WordPress Autoptimize cannot write to the cache directory
  • Create and delete WordPress sites in XAMPP with a batch file
  • How to fix “Error: MySQL Shutdown Unexpectedly” in XAMPP control panel

Copyright © 2025 · Maker Pro on Genesis Framework · WordPress · Log in