Enhancing and changing ElasticProbe with custom code

There are special use cases that require you to extend or enhance ElasticProbe’s plugin default functionality. For example, filtering search query parameters or changing the order of search results. In these cases, it is not advisable to change the plugin code directly, as this would lead to the loss of custom code when upgrading the plugin.

There are 3 different methods that enables this custom code to function. Let’s check them out but before that make sure to always backupĀ  your website before making changes.

Your theme’s “functions.php” file

functions.php is the most used place when you don’t want to install extra plugins. However, this method might not be suitable for beginners as coding errors could lead to site breaks.

If you are choosing this method, be sure to use a child theme. Using the main theme would result in code loss when it is upgraded.

You can change the functions.php file through you hosting panel (For shared hosting), sFTP or in the Wordpress admin dashboard on Appearance-> Theme File Editor-> Select your theme-> Select functions.php file.

On the occasion of an error in your custom code, your website might break and therefor you need to remove the custom code through sFTP or your hosting panel (shared hosting). If all else fails and the error persists, restore from your backup.

Custom plugin

In the case of multisite installations, it might be easier to add your custom code to a custom plugin and install that plugin. Check out WordPress plugin handbook for reference but here is a short description:

  • Create a PHP file with your custom code and ZIP it.
  • On your Wordpress admin dashboard go to Plugins-> Add New Plugin
  • Click on Upload Plugin and select the ZIP file.
  • Activate the newly installed plugin

Using a snippets plugin for custom codes

There are numerous different snippets plugin on the Wordpress plugin repository that can be used to hold your custom code. One example is WPCode Lite among others.