Problem requiring/including plugin files with plugin_dir_path( __FILE__ )

When using plugin_dir_path() like you do:

plugin_dir_path( __FILE__ );

It does return something like:

/var/www//wordpress/wp-content/plugins/your-plugin/

So it adds a trailing slash, because as the documentation states:

It is a wrapper for trailingslashit( dirname( $file ) );.

So remove the slash before the file in your calls:

require_once plugin_dir_path( __FILE__ ) . 'file.php';

Leave a Comment