Title: cannot retrieve data using $wpdb
Last modified: August 21, 2016

---

# cannot retrieve data using $wpdb

 *  [pedenski](https://wordpress.org/support/users/pedenski/)
 * (@pedenski)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/cannot-retrieve-data-using-wpdb/)
 * in my custom_plugin.php im trying to retrieve the pages on my database using 
   this statement below.
 * but i dont 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/>';
   
           }
       ```
   

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/cannot-retrieve-data-using-wpdb/#post-4045064)
 * Try changing this:
 *     ```
       $posts = $wpdb->wp_posts;
       ```
   
 * to this:
 *     ```
       $posts = "$wpdb->posts";
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘cannot retrieve data using $wpdb’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [12 years, 9 months ago](https://wordpress.org/support/topic/cannot-retrieve-data-using-wpdb/#post-4045064)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
