I'd like to read the database settings in wp-config.php. However, if I do a require("wp-config.php"); it loads up the entire WordPress environment.

Is there any way to avoid this?

1 Answer 1


Actually you can read all the constants defined in wp-config.php from any place you want. If you have something like this in your wp-config.php

define('DB_NAME', 'some_value');

You can do this for example in your functions.php file

echo DB_NAME;

Constants are globally accessible from everywhere.

So please think about this approach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.