How to get the current plugin directory in WordPress

0 votes

I need to get the current plugin directory like

[wordpress_install_dir]/wp-content/plugins/plugin_name

(if getcwd() called from the plugin, it returns [wordpress_install_dir], the root of installation)

thanks for help

May 8, 2020 in PHP by kartik
• 37,520 points
14,735 views

1 answer to this question.

0 votes

Hello @kartik,

This will actually get the result you want:

<?php plugin_dir_url(__FILE__); ?>

Hope this works!!

Thank you!

answered May 8, 2020 by Niroj
• 82,800 points

Related Questions In PHP

0 votes
1 answer

How to get the client IP address in PHP ?

Hello, Here is a code sample of a good ...READ MORE

answered Apr 8, 2020 in PHP by Niroj
• 82,800 points
7,836 views
0 votes
1 answer

How to get current route in Symfony 2?

Hii,  The easiest way to do this: class MyController ...READ MORE

answered