How can I make an external PHP library available with my plugin.

Where the library files need to be placed?

2 Answers 2


The best way to include an external library is to put it in your plugins folder. Then just use require_once() wherever you need it. Depending on the size of the plugin and your type of programing this might be in the main plugin file or wherever you need that functionality.


There is no central library folder for WordPress like you have for drupal. So you just include the library files within your plugin's folder and use the function plugin_dir_path to figure out the include path.

Another alternative is to distribute the library files as a separate plugin and then use TGM plugin activation to "require" that plugin:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.