I have a WordPress site that uses two databases — one section queries one database (“database_A”), and then WordPress makes its connection to its own database (“database_B”).
Everything it working well until I go to call this function:
$pageposts = $wpdb->get_results($querystr, OBJECT);
The WordPress suddenly selects the wrong database (“database_A”) when it was just using (“database_B”).
How do I (a) prevent it from selecting (“database_A”) or (b) make a call to have it select (“database_B”)?
The wpdb class in WP ha a select() method. You should just be able to call it directly.
You could also instantiate a second object that uses database_b: