Make WordPress Core


Ignore:
Timestamp:
04/02/2006 12:33:10 AM (20 years ago)
Author:
ryan
Message:

Some optimization of the post query. #2604

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/template-functions-links.php

    r3647 r3678  
    471471   
    472472    if ( 'posts' == get_query_var('what_to_show') ) {
    473         preg_match('#FROM\s(.*)\sGROUP BY#siU', $wp_query->request, $matches);
     473        preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
    474474        $fromwhere = $matches[1];
    475475        $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
     
    477477    } else {
    478478        $posts = $wp_query->posts;
    479         preg_match('#WHERE\s(.*)\sGROUP BY#siU', $wp_query->request, $matches);
     479        preg_match('#WHERE\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
    480480        $where = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]);
    481481        $num_days = $wpdb->query("SELECT DISTINCT post_date FROM $wpdb->posts WHERE $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date)");
Note: See TracChangeset for help on using the changeset viewer.