Determine Path To Plugin and Content Directories

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“.

Comments are closed.


  1. kamal

    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?

  2. Michael

    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.

2 pingbacks

  1. WordPress Verzeichnisse bestimmen - []
  2. WordPress - Return URL - WP Engineer