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 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.
This question already has answers here: Using wpdb to connect to a separate database (6 answers) Closed 6 years ago.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/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.
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);
references:
https://wordpress.stackexchange/a/1673/86845
https://stackoverflow/a/36759606/3204142