WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a developer who is accessing the wp-config file directly to get database information. I would think that WP has a better way to do this. What do you think community?

share|improve this question
Global $wpdb; codex.wordpress.org/Class_Reference/wpdb – Bainternet Dec 7 '11 at 16:54
I suppose it depends specifically what database information you're talking about, not sure $wpdb holds data on the database name, the user or password(for the db connection), so including may be the only sure way to grab that info in a reliable manner unless you're happy to hardcode that info and update it from time to time. – t31os Dec 7 '11 at 17:55
Thanks guys for the input! – mattrepublic Dec 9 '11 at 16:37
up vote 0 down vote accepted

I am not aware of a Wordpress function to do this. But have a look at this search and replace tool:


This achieves what you want by reading in the wp-config file and scanning through it. Have a look at the function "icit_srdb_define_find" on line 374.

share|improve this answer
Thanks for the reference ZweiBlumen – mattrepublic Dec 9 '11 at 15:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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