I have an extarnal database that I want to show some data in my wordpress site. What are the necessary steps to achieve this?

edit: I changed config.inc.php according to https://stackoverflow.com/questions/16801573/how-to-access-remote-server-with-local-phpmyadmin-client but it enabled me to see the hostName of the external server visible by phpmyadmin. With the wordpress root I can enter the external database.

Up to here is good. But I do not have any clue about how to advance. I searched plugin to show the new database but I could not find any. I am new to the wordpress, so pardon me for my beginner questions. I want to show the data in different pages, with the unique string name that is the same as in the external database, ie: page name is the specifier query name.

  • Can you provide some more details on what you're trying to achieve? WordPress is built on PHP so you can use regular PHP to access any database you want.
    – mrben522
    Jan 24 '19 at 21:31

You can use wpdb to setup a new connection.

Add something similar to this below in your functions.php and you can then query just like you would normally but using the new connection.

$second_db = new wpdb(DB_USER, DB_PASSWORD, $database_name, DB_HOST);
$results = $second_db->get_results($your_query);




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