I'm trying to retrieve information on my database. I wanted to display all pages using this statement, but I'm getting a blank ARRAY
global $wpdb; $result = $wpdb->get_results ( " SELECT * FROM $wpdb->wp_posts WHERE post_type = 'page' " ); echo $result; // display data Output:
ARRAY EDIT: After changing below suggestions, I'm now using this. but I still don't get any results:
global $wpdb; $posts = $wpdb->wp_posts; $result = $wpdb->get_results( " SELECT * FROM $posts WHERE 'post_type' = 'page' " ); foreach ($result as $page) { echo $page->ID.'<br/>'; }
$wpdb->wp_postswith curly braces, ie.{$wpdb->wp_posts}..