Retrieve WordPress root directory path?

后端 未结 13 1434
闹比i
闹比i 2020-11-28 07:48

How can I retrieve the path to the root directory in WordPress CMS?

13条回答
  •  野性不改
    2020-11-28 08:40

    Looking at the bottom of your wp-config.php file in the wordpress root directory will let you find something like this:

    if ( !defined('ABSPATH') )
        define('ABSPATH', dirname(__FILE__) . '/');
    

    For an example file have a look here:
    http://core.trac.wordpress.org/browser/trunk/wp-config-sample.php

    You can make use of this constant called ABSPATH in other places of your wordpress scripts and in most cases it should point to your wordpress root directory.

提交回复
热议问题