Save custom post type to external database

I have been searching for an answer to this question for over a month now – i do not think wordpress is very good for any site that has a secure external DB or for anyone who does not want to store customer data in the main wordpress database, which is strange as that seems like a highly valued function.

At any rate i came across this code during my research that may help you – it is a global variable for a external DB… according to the author it is usable in the same way as $wpdb global variable is used.

If you want the author’s full blurb on it go here https://bavotasan.com/2011/access-another-database-in-wordpress/

The code is:
$newdb = new wpdb($DB_USER, $DB_PASSWORD, $DB_NAME, $DB_HOST);
$newdb->show_errors();

Hopefully it is of some use to you…