Title: Query and display data (custom posts?)
Last modified: August 20, 2016

---

# Query and display data (custom posts?)

 *  [Preserved](https://wordpress.org/support/users/preserved/)
 * (@preserved)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/query-and-display-data-custom-posts/)
 * I’m looking to query the wp_posts table for a specific post type, then display
   it on a page.
 * So far I’ve come up with this, and when placed on a custom template it does nothing
   ~:
 * <?php
    global $wpdb; $customers = $wpdb->get_results(“SELECT * FROM wp_posts 
   WHERE post_type = ‘businesses;”);
 * wcho “<table>”;
    foreach($customers as $customer){ echo “<tr>”; echo “<td>”.$
   customer->post_title.”</td>”; echo “</tr>”; } echo “</table>”; ?>
 * What am I missing?

Viewing 1 replies (of 1 total)

 *  Thread Starter [Preserved](https://wordpress.org/support/users/preserved/)
 * (@preserved)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/query-and-display-data-custom-posts/#post-2862413)
 * More on this. I’ve sort of got something working:
 * <div class=”entry-content”>
    <p><?php _e(‘Interested in what I have to say by
   category? Well you can search below…’, ‘genesis’); ?></p>
 * <h4><?php _e(‘Exhibitors’, ‘genesis’); ?></h4>
    - <?php $recent = new WP_Query(“post_type=businesses&showposts=20”); while($
      recent->have_posts()) : $recent->the_post();?>
    -  | <?php the_date(); ?>
    - <?php endwhile;?>
 * </div>
 * The above works, however I’d like to include some information that’s in the posts_meta
   table. I’d like the link that surrounds the title to be the www entry for this
   post which is held in the meta data. Is there a way? or am I going down a dead-
   end by using wp_query?

Viewing 1 replies (of 1 total)

The topic ‘Query and display data (custom posts?)’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [Preserved](https://wordpress.org/support/users/preserved/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/query-and-display-data-custom-posts/#post-2862413)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
