Site Specific Plugin for Executing Code Snippet

I know a lot of us come across various code snippets while searching for a solution to a given problem pertaining to WordPress.
More often than not, you will be told to include the code snippet in your theme’s functions.php file.

This practice has its shortcoming – the code snippet disappears after a theme is updated.

Rather than adding code to theme’s functions.php, a site specific or custom functionality plugin is better.

All code hacks and snippets used by my WordPress blog are all in a dummy plugin named Hacks and Code.

Creating a dummy plugin

Follow the steps below to learn how dummy plugins are created taking my Hacks and Code plugin as an example.

  1. In WordPress plugin folder (/wp-content/plugins), create a PHP file name my-hacks-code.php.
  2. Add a plugin header as follows
    
    <?php
    /*
     Plugin Name: Hacks and Code
     Plugin URI: https://w3guy.com
     Description: WordPress code snippet den
     Author: Collizo4sky
     Author URI: https://w3guy.com/about/
     */
    
  3. Dump the code snippet and save.
  4. Go to your WordPress dashboard and activate the plugin.

When next you have a WordPress code snippet, dump it to the site specific plugin.

Don’t miss out!
Subscribe to My Newsletter
Invalid email address