Title: Which query to use
Last modified: August 19, 2016

---

# Which query to use

 *  [mittwordpress](https://wordpress.org/support/users/mittwordpress/)
 * (@mittwordpress)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/which-query-to-use/)
 * Hi,
    I want to display links below each post on the startpage. Based on a list
   of IDs for each post. Now I use custom queries and the `$get_res = wpdb->get_results(
   $querystr, ARRAY_A)`
 * I found it more easy to work with, but is it very bad to do it this way rather
   than a get_posts and the post__in, performance wise?
 * I found a discussion about it where some argued wp_super_cache wouldnt perform
   as well when using custom queries.
 * the custom query is a simple one
 *     ```
       $querystring = SELECT p.ID, p.post_title, date_format(p.post_date, '%d/%c') as formatted_date
           FROM $wpdb->posts p
           WHERE p.ID IN ($the_ID_list)
       	AND p.post_status = 'publish'
       	AND p.post_type = 'post'
           ORDER BY p.post_date DESC
       ```
   

Viewing 1 replies (of 1 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/which-query-to-use/#post-1440475)
 *     ```
       <?php
       //$the_ID_list = '476,419,72';
       $args=array(
         'post__in' => explode("," , $the_ID_list),
         'orderby' => 'date',
         'order' => 'DESC',
         'post_type' => 'post',
         'post_status' => 'publish',
         'posts_per_page' => -1,
         'caller_get_posts'=> 1
       );
       $my_query = null;
       $my_query = new WP_Query($args);
       if( $my_query->have_posts() ) {
         echo 'List of Posts';
         while ($my_query->have_posts()) : $my_query->the_post(); ?>
           <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
           <?php
         endwhile;
       }
       wp_reset_query();  // Restore global post data stomped by the_post().
       ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Which query to use’ is closed to new replies.

## Tags

 * [query](https://wordpress.org/support/topic-tag/query/)
 * [super cache](https://wordpress.org/support/topic-tag/super-cache/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 1 month ago](https://wordpress.org/support/topic/which-query-to-use/#post-1440475)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
