Make WordPress Core

Changeset 3694


Ignore:
Timestamp:
04/05/2006 08:48:29 PM (18 years ago)
Author:
ryan
Message:

Paging fixes.

File:
1 edited

Legend:

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

    r3678 r3694  
    474474        $fromwhere = $matches[1];
    475475        $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
    476         return ceil($numposts / get_option('posts_per_page'));
     476        $max_num_pages = ceil($numposts / get_option('posts_per_page'));
    477477    } else {
    478478        $posts = $wp_query->posts;
    479         preg_match('#WHERE\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
    480         $where = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]);
    481         $num_days = $wpdb->query("SELECT DISTINCT post_date FROM $wpdb->posts WHERE $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date)");
    482         return ceil($num_days / get_option('posts_per_page'));
    483     }
     479        preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
     480        $fromwhere = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]);
     481        $num_days = $wpdb->query("SELECT DISTINCT post_date FROM $fromwhere GROUP BY year(post_date), month(post_date), dayofmonth(post_date)");
     482        $max_num_pages = ceil($num_days / get_option('posts_per_page'));
     483    }
     484
     485    return $max_num_pages;
    484486}
    485487
Note: See TracChangeset for help on using the changeset viewer.