how to get plugin directory path in wordpress

Solutions on MaxInterview for how to get plugin directory path in wordpress by the best coders in the world

showing results for - "how to get plugin directory path in wordpress"
Melina
30 Oct 2018
1//current path: /home/user/var/www/wordpress/wp-content/plugins/my-plugin/
2$dir = plugin_dir_path( __DIR__ );
3//$dir is set to /home/user/var/www/wordpress/wp-content/plugins/
4
Athene
15 Nov 2020
1if ( is_admin() ) {
2    include_once( plugin_dir_path( __FILE__ ) . 'includes/admin-functions.php' );
3} else {
4    include_once( plugin_dir_path( __FILE__ ) . 'includes/front-end-functions.php' );
5}
6
Athénaïs
27 Jun 2017
1function enqueue_scripts() {
2    wp_enqueue_script( 'custom-js', plugin_dir_url( __FILE__ ) . 'js/custom.js', array( 'jquery' ), '', true );
3    wp_enqueue_style( 'style-css', plugin_dir_url( __FILE__ ) . 'css/style.css' );
4}
5add_action( 'wp_enqueue_scripts', 'enqueue_scripts');
6 
7function admin_enqueue_scripts() {
8    wp_enqueue_script( 'custom-js', plugin_dir_url( __FILE__ ) . 'js/custom.js', array( 'jquery' ), '', true );
9    wp_enqueue_style( 'style-css', plugin_dir_url( __FILE__ ) . 'css/style.css' );
10}
11add_action( 'admin_enqueue_scripts', 'admin_enqueue_scripts');
12
Cillian
16 May 2016
1define( 'MY_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
2include( MY_PLUGIN_PATH . 'includes/admin-page.php');
3include( MY_PLUGIN_PATH . 'includes/classes.php');
4// etc.
5
Giorgio
11 Jun 2016
1foreach ( glob( plugin_dir_path( __FILE__ ) . "subfolder/*.php" ) as $file ) {
2    include_once $file;
3}
4
Andrea
20 Jul 2020
1$dir = plugin_dir_path( __FILE__ );
2// Example: /home/user/var/www/wordpress/wp-content/plugins/my-plugin/
3
Ilaria
08 Aug 2018
1/**
2 * Include CSS file for MyPlugin.
3 */
4function myplugin_scripts() {
5    wp_register_style( 'foo-styles',  plugin_dir_url( __FILE__ ) . 'assets/foo-styles.css' );
6    wp_enqueue_style( 'foo-styles' );
7}
8add_action( 'wp_enqueue_scripts', 'myplugin_scripts' );
9
10Answer
11http://example.com/wp-content/plugins/my-plugin/assets/foo-styles.css
12
Adriana
03 Jun 2017
1function plugin_dir_path( $file ) {
2    return trailingslashit( dirname( $file ) );
3}
4
queries leading to this page
plugin file pathwordpress plugin folder pathwordpress plugin directory path urlhow to change path wordpress plugin directorywordpress get plugins disrectory pathwordpress plugin dir pathwordpress get the directory of a pluginwordpress path to pluginswp get plugin dir pathplugin dir path theme wordpresswordpres get plugin dirplugin wordpress directorycurrent plugin path wordpressget plugin directorywordpress plugin directory pathget plugins folder path wordpressget path of plugin wordpresshoq to get plugins directorywordpress directory pathhow to get plugin path wordpressplugin dir path in wordpresswordpress to get plugin pathwordpress get pathwordpress get path to pluginplugin file path wordpressget plugin filesplugin dir filewordpress get plugin pathwp plugin url pathwordpress plugins directory path urlwordpress plugin show directoryget plugin url path wordpresswordpress get plugin urlhow to get js path from plugin directory wordpresswordpress get plugin directory namewordpress developer get plugin directorywordpress get plugins pathwordpress get path to plugins folderget plugin directory wpwordpress include the root directory path in pluginget plugin directory urlget plugins url wordpresswhich is plugin base directory wordpresshow to get plugin directory path in wordpresswordpress get plugin directory urlwp plugin folder pathwordpress php get plugin directoryget current plugin url wordpressget plugin directory url wordpressshow directory wordpress pluginwordpress directory path in plugin fileget path of plugin directory wordpressget the plugin directory in wordpressplugin pathplugin dirwp get plugin directoryplugin dir wordpresswordpress get plugin path urlget file path under a plugin wordpressget plugin dir path wordpresswordpress plugin include from plugin rootwordpress get plugin folderget plugin root path wordpressget plugin folder path wordpresswordpress local plugin folder pathwordpress get plugin directory path urlwp plugin base urlwordpress current plugin pathwordpress get plugin root urlpath to plugin directory wordpresswp plugin directory pathplugin directory pathplugin path in wordpressget wordpress plugin file directoryplugin directory path wordpresswordpress get plugin directory pathrecommended wordpress plugins folder pathget plugin path wordpressplugin dir pathwordpress how to get plugin pathget wordpress url in pluginget plugin directory urlget plugin urlwordpress get plugin url pathwp get pluygin urlhow to get the plugin dir path on the wordpress comget path of plugin directory wordpress javascriptplugin path to a plugin wordpressplugin directory path wpwordpress path to plugin directorywordpress get plugins directorywordpress get plugin directoryhow to get wordpress plugin directorywordpress plugins pathpath to plugin asset wordpressget public plugin url wordpresswordpress plugin php url of plugin fileswordpress local plugin folder directoryget plugin directory wordpress phpwordpress get plugin directory from function phpplugin dir path wpwordpress plugins folder pathget plugin root directory wordpresswordpress plugin path urlwordpress php get plugin pathwordpress download plugin from pathpath to current plugin wpwordpress plugin directory urlwordpress plugin root directorywordpress get current plugin pathhow to give plugin file path in wordpresswordpress plugin pathpath function woocommercewordpress get plugin root pathplugin path wordpresswordpress plugin get path directorywp get plugin pathget plugin folder url wordpressget plugin directory wordpresswp get plugin directory pathwordpress plugin show a directory in a pagefunction to return dir path in wpget plugin directory in wordpressplugin path wpwordpress plugin dir pathwordpress plugin directoryget plugin pathwordpress plugin get plugin directoryphp get path of pluginhow to get plugin directory path in wordpress