Go to

It is quite common that when you purchase pre-packaged software (like a WordPress plugin) it is missing a feature you would really like to have. I get such questions quite often, usually, if the feature customer needs require a couple of minutes to custom code I will do that as a part of our support.

Creating the snippet is fast, but explaining where to put is a bit complex, especially since the most efficient way to do it is also the most difficult.

Creating Custom Plugin

The absolutely best method to store custom code snippets is to have a custom separate plugin where you will be adding them (ideally with documentation so you will know what each snippet does).

There are multiple advantages to this method:

  • You will have all snippets in a single place.
  • Your snippets will not be overwritten on a WordPress, plugin, or theme update.
  • There are no performance disadvantages.
  • You can edit the changes from wp-admin / Plugins / Editor panel if you want to and WordPress will prevent you from saving the changes if you will make a mistake.

To get started use the Download button below to download the My Custom Codes plugin then install and activate it on your website from wp-admin / Plugins / Add New / Upload panel.

If you are wondering what is inside this plugin, then by default it is just a PHP file with a plugin header

<?php
/*
Plugin Name: My Custom Codes
Plugin URI: https://wpadverts.com/
Description: My various custom code snippets
Author: Me
Version: 1.0
*/

// Paste the snippets below ...

In other words, the “My Custom Codes” plugin is just a container for your custom code snippets, by default it does not do anything.

Once you have the plugin installed and activated, you can go to wp-admin / Plugins / Plugin Editor panel, and in the dropdown on the right side select “My Custom Codes” you should see a screen like on the image below

Plugin editor allowing you to add code snippets

On line 12 you can start adding your code snippets, ideally, you should also consider adding some comments above each snippet so you will know what the snippets do, but this is optional.

Troubleshooting

I am seeing an error while trying to save changes?

The error like on the image above suggests that there is some kind of error in the code you have pasted, usually, the problem will be that you have the code copied along with the PHP opening tag <?php, if that is the case try removing it and click “Update File” again.

I do not see wp-admin / Plugins / Plugin Editor menu?

The problem most likely is the one of the below:

  • You are most likely logged in as a user who does not have edit_plugins capability, that is a user with a role different than Administrator.
  • Editing plugins with Plugin Editor is disabled.

If you are no logged in as an Administrator you would need to logout and log-in as an Administrator as only then you will be able to edit the plugins.

If you are already an administrator then open file wp-config.php and look there for the following line

define('DISALLOW_FILE_EDIT', false);

Once you will find it, either change “false” to “true” or remove this line, you should then see the wp-admin / Plugins / Editor panel.

Leave a Message

Ready to build a better classified website?

Seamless WordPress integration, No Coding Required, Helpful Support