I'm attempting to retrieve data from a separate WordPress installation on the same server. I'm able to use the wpdb class to successfully connect to the alternate database and get results, however, I can't seem to use the class methods with my newly created database.
For clarification: I have 2 Wordpress installations. I am attempting to retrieve posts from one database into a page from the other installation. The new database is another basic Wordpress database.
This works and brings me data:
$query = " SELECT * FROM wp_posts WHERE post_type='post' AND post_status='publish' "; $rows = $newdb->get_results($query, ARRAY_A);
This fails to get results:
$query = " SELECT * FROM $newdb->posts WHERE post_type='post' AND post_status='publish' "; $rows = $newdb->get_results($query, ARRAY_A);
I'm using the following to connect the database:
$newdb = new wpdb('username','password','database','localhost');
All of the material I've found uses the wpdb methods to interact with the new database and I'm having trouble making my queries more complex without the ability to use them.
What am I missing?