Having some troubles with a PHP script I am trying to build.
I need to access the a file which is located in the root folder of my Wordpress install:
wordpress-root/live-config.php
Problem is, my script file is located inside the theme's root folder, and I'm trying to access the root folder when defining a constant.
My script file is located in: root-directory/wp-content/themes/theme-root/
If I use require ABSPATH . 'live-config.php';
it's no good because it looks in the directory where your current file is (ie. theme-root directory instead of my wordpress-root).
I just want to know what the best way would be to grab the root folder of my Wordpress install when defining a constant which is in the theme directory?
In my script, I'm currently trying:
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/**
* Define type of server
*
* Depending on the type other stuff can be configured
* Note: Define them all, don't skip one if other is already defined
*/
define( 'WP_DEV_SERVER', file_exists( ABSPATH . 'dev-config.php' ) );
/**
* Load DB credentials
*/
if ( WP_DEV_SERVER )
require ABSPATH . 'dev-config.php';
else
require ABSPATH . 'live-config.php';
But obviously defining ABSPATH in my theme-root does not actually point to the wordpress-root directory.