How to symlink a plugin located outside your local WordPress installation

When you clone a WordPress plugin, you’ll often need to run build scripts to build a usable version of the plugin in your WordPress plugins directory. You can create a symlink in your plugins directory to the plugin instead of cloning the repository to your WordPress installation directly.



Prerequisites

Before creating a symlink, you’ll need the following:

  • Local WordPress installation
  • Clone of a plugin to a directory outside your local WordPress installation
  • ln command-capable operating system

Creating a symlink

To create a symlink, open a terminal window, then use the following command:

ln -s /Users/yourusername/Desktop/somefolder/plugin-slug /Users/yourusername/Sites/localhost/wordpress/wp-content/plugins
  • The first path is where your cloned plugin resides
  • The second path is where you want the symlink from

Remember to change the paths in my example to your paths.


Why do it?

Often you’ll want to keep cloned plugins separate from your local WordPress installation. Lots of plugins have their own build scripts, which must be run to be able to perform development tasks and “build” the plugin so it can be used as if an end user.

For example, the WooCommerce plugin has subdirectories for various projects, including WooCommerce itself, each containing their own build scripts. Before the WooCommerce plugin can be used, you need to build it, and therefore to use it, you’ll need to symlink the resulting directory from the build to your local WordPress installation’s plugins directory.

Leave a comment

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