Make WordPress Core

Changeset 2855


Ignore:
Timestamp:
09/08/2005 09:05:07 PM (19 years ago)
Author:
ryan
Message:

posts_nav_link fixes from Denis-de-Bernardy. fixes #789

File:
1 edited

Legend:

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

    r2803 r2855  
    438438                $max_page = $max_num_pages;
    439439            } else {
    440         preg_match('#FROM (.*) GROUP BY#', $request, $matches);
     440        preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);
    441441        $fromwhere = $matches[1];
    442         $numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $fromwhere");
     442        $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
    443443        $max_page = $max_num_pages = ceil($numposts / $posts_per_page);
    444444            }
     
    480480        if (get_query_var('what_to_show') == 'posts') {
    481481            if ( ! isset($max_num_pages) ) {
    482                 preg_match('#FROM (.*) GROUP BY#', $request, $matches);
     482                preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);
    483483                $fromwhere = $matches[1];
    484                 $numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $fromwhere");
     484                $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
    485485                $max_num_pages = ceil($numposts / $posts_per_page);
    486486            }
Note: See TracChangeset for help on using the changeset viewer.