Access to second database from php include breaks WP queries after.
-
Hoping there’s a guru here who can give me a quick and simple answer.
I’m working on some custom page templates, which involves accessing a pre-existing database that is NOT part of my WP install, to retrieve data back into my WP theme. Basically I include a config file that connects to the NON-WP database, run some queries, output the info, and carry on with the rest of the page via WP functions.
And while my included queries work just fine, PHP is now connected to a different database, and stops loading up the rest of the WP content. If I do this in the theme header, it takes out my custom menu, formatting for things like galleries, etc.
How do I tell WP to re-connect to the WP database after I’m done in the other one? I took a look through the wpdb function reference, but there is no mention in there of how to connect to another db, just that you should instantiate your own object from the wpdb class.
I’m sure it’s probably something very simple, for someone who already knows what they’re looking for.
- The topic ‘Access to second database from php include breaks WP queries after.’ is closed to new replies.