How to Get WordPress DataBase Name with PHP

To get your WordPress database name with PHP inside a WordPress plugin or theme file, simply use this simple PHP code:

//Get the db name using $wpdb:
global $wpdb;
$deename = $wpdb->dbname;
echo “Your Database: $deename<br />”;

The first line, global $wpdb initiates the wpdb class in WordPress which has a lot of handy MYSQL database functions within WordPress. Learn more about wpdb HERE.

Leave a Reply

Your email address will not be published. Required fields are marked *