[wp-testers] previous_posts_link() buggy ?

e-head ebone+wp-testers at dotsandloops.net
Tue Apr 26 15:45:52 GMT 2005


On 04/25/05 17:15 or thereabouts, Ryan Boren scribbled:
> On Mon, 2005-04-25 at 17:30 -0400, e-head wrote:
> > This function sometimes creates a link when there are no more posts.
> > 
> > I've had this problem for a while now.
> > 
> > You can see an example of it here:
> > http://dotsandloops.net/page/19/
> > 
> > click "older" twice ... it will throw up the "Sorry, no posts matched
> > your criteria." message.
> > 
> > you can also see it here:
> > http://dotsandloops.net/blog/category/pictures/
> > 
> > Interestingly ...
> > My pictures category was working fine till I edited some of the posts
> > and added them to another category (cute) in addition to the pictures
> > category ... then I started getting the erroneous "- older" link with
> > previous_posts_link().
> 
> If you page by days (rather than posts), this will happen.  We currently
> don't have code that will calculate the max number of pages when paging
> by days.
> 
> Ryan

With the help of Splee on #wordpress I think I fixed my problems.

I changed the following line in the previous_posts_link() function
(found in template-functions-links.php):

before:
$numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $fromwhere");
after:
$numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");

-- 
	A domineering man married a mere wisp of a girl.  He came back from
his honeymoon a chastened man.  He'd become aware of the will of the wisp.


More information about the wp-testers mailing list