Why you should move your personal site configuration to a plugin

Most people add useful code snippets to their WordPress site using their theme’s functions.php file – simply add the code to the end and all is good. But there are a number of downsides to this solution which can be simply cured by converting them to a plugin. Let me explain why and how you can do this.

First of all the issues with using functions.php

  1. Your theme may also use this file so any update to your theme will cause all your own modifications to be lost
  2. It’s theme-specific so if you change to another theme at a later time, you need to copy over your changes to that theme’s file
  3. It’s harder to recover from a fatal error in this file than, say, one in a plugin
  4. When you have site issues and need to rule out code that could be causing it, you can’t disable this – if it’s a plugin you can temporarily disable this and ensure none of your changes are the cause

And that’s exactly what I do with this site – all my personal modifications are in a plugin named ‘Artiss.blog Configuration’. 

To convert to a plugin, simply create a new .php file with your code in. Then add the following to the top…

<?php
/*
Plugin Name: Artiss.blog Configuration
Plugin URI: https://artiss.blog
Description: Configuration Settings for Artiss.blog
Author: David Artiss
Author URI: https://artiss.blog
*/

Obviously, you’ll need to change the various bits of meta data to be appropriate to your site. But, otherwise, this can then be uploaded to your site as a plugin and activated as normal.

Talk to me!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from David Artiss

Subscribe now to keep reading and get access to the full archive.

Continue reading