Determine Path To Plugin and Content Directories
September 26th, 2008 by Frank • WordPress Hacks • 4 Comments
If you like to write a Plugin and you want to keep it downward compatible, then check beforehand the constants, because since WordPress version 2.6 you can rename the folder wp-content and this will also change the path to the Plugin folder.
Just a few lines of code are enough and you can work with the „new“ constants.
// Pre-2.6 compatibility if ( !defined( 'WP_CONTENT_URL' ) ) define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' ); if ( !defined( 'WP_CONTENT_DIR' ) ) define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); if ( !defined( 'WP_PLUGIN_URL' ) ) define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' ); if ( !defined( 'WP_PLUGIN_DIR' ) ) define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); if ( !defined( 'WP_LANG_DIR') ) define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' );
I use this solution quite a long time. You can find the solution in the WordPress Codex now - „Determining Plugin and Content Directories“.
Info
- Published in WordPress Hacks
- Tags: Code, Constants, PHP, WordPress, WordPress Plugins
- Comment feed | Trackback URL
- read: 3782 | today: 2
- leave a Comment



Hi, and thanks for this information.
as i'm a new wordpress and PHP user, wher can i insert this code? and is it possible to rename the folder "wp-content" to any name?
Thanks
kamal, the code above is for theme-/ plugin authors. You can define the wp-content in your wp-config.php. Here is a good overview.