I am trying to pull data from a table I have imported into my wordpress database. My php code works for all the default wp_ tables but when try and target the tables I actually want I get bugger all back.
My code (currently echoing all post titles and it works)
$liveposts = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->posts
WHERE post_status = 'publish'") );
foreach ($liveposts as $livepost) {
echo '<p>' .$livepost->post_title. '</p>';
}
I imported 3 tables from another database, and yes they do have data in to pull out. I found out that the $wpdb->posts
expects the posts table to be wp_posts.. so I tried renaming my tables to wp_bus_route... but still nothing.
I used myphpadmin to export 3 tables out of a large database (in a .sql format) and imported them. i can see the tables in myphpadmin and view all the data in them.
This is my 1st time pulling data from the wp database so i ma of missed something obvious. any pointers please :)