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 in PHP by kartik
• 27,360 points
169 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 by Niroj
• 58,960 points

Related Questions In PHP

0 votes
1 answer

How do I get all posts from $wp_query in the search results in wordpress?

Hello @kartik, Set posts_per_page parameter in args to ...READ MORE

answered May 8 in PHP by Niroj
• 58,960 points
332 views
0 votes
1 answer

How to load Javascript in Wordpress Plugin?

Hello kartik, You need to specify when the ...READ MORE

answered May 8 in PHP by Niroj
• 58,960 points
64 views
0 votes
1 answer

How to get the request parameters in symfony2

Hello @kartik, The naming is not all that ...READ MORE

answered Aug 14 in PHP by Niroj
• 58,960 points
42 views
0 votes
1 answer

How to get a list of user accounts using the command line in MySQL?

Hello @kartik, Use this query: SELECT User FROM mysql.user; Which ...READ MORE

answered Aug 17 in PHP by Niroj
• 58,960 points
33 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18 in Laravel by Niroj
• 58,960 points
2,207 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18 in Laravel by Niroj
• 58,960 points
246 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23 in Laravel by Niroj
• 58,960 points
191 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23 in Laravel by Niroj
• 58,960 points
2,771 views
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 in PHP by Niroj
• 58,960 points
1,323 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 Apr 15 in PHP by Niroj
• 58,960 points
128 views