I’m trying to get the path location of my wordpress plugin. I don’t mind if I have to get it via code or via checking the sources on my google devtools. I tried doing it via my sources on devtool but didn’t find it. I’m new to PHP and WP so I don’t know much how scoping works.
When I go to devtools I don’t see my plugins folder but the plugin is working and When I go to the admin console, I do see my plug in activated.
2
Answers
Chrome dev – go to Sources and then expand the wp-content folder, and then the plugins folder.
WordPress plugins are usually found at this path:
https://your_domain.com/wp-content/plugins/the_plugin_folder
Your chrome dev tools won’t mirror your local file structure. It’s showing folders where assets are being loaded from. If your plugin doesn’t load any CSS / JS, it won’t be listed.
To get your plugin’s directory URL, add the following code:
If you want the path instead, use:
Either line must be used from within the plugin.
Docs:
https://developer.wordpress.org/reference/functions/plugin_dir_url/
https://developer.wordpress.org/reference/functions/plugin_dir_path/