Skip to main content
1 of 2
xaedes
  • 1.3k
  • 1
  • 11
  • 14

It is checked for the wp-config.php. This can of course be changed to other wordpress core files.

function find_wordpress_base_path() {
    $dir = dirname(__FILE__);
    while( $dir = realpath("$dir/..") ) {
        //it is possible to check for other files here
        if( file_exists($dir."/wp-config.php") ) {
            return $dir;
        }
    }
    return null;
}
xaedes
  • 1.3k
  • 1
  • 11
  • 14