Word Press plugin directory

Word Press plugin directory

by Expert of Tech

Get Word Press plugin directory using WP_PLUGIN_DIR constant . It’s most important when you develop a plugin. See below code example:
$dir = plugin_dir_path( __FILE__ );
// Example: /home/user/var/www/wordpress/wp-content/plugins/my-plugin/
echo  WP_PLUGIN_DIR.'/plugin-name';

Additional Solution to get Word Press plugin directory

$plugin_dir = ABSPATH . 'wp-content/plugins/plugin-folder/';

The best practice is to use the latest version is WP_PLUGIN_DIR as below. so copy and paste the code into the template file. you can file more details here.

$plugin_dir = WP_PLUGIN_DIR . '/plugin-folder';

In conclusion, That’s all about it. But, if you face any difficulties, feel free to contact one of our experts or email me. I will respond ASAP. To learn more about WordPress speed optimization, click here.

Share it