Make WordPress Core

Opened 18 years ago

Closed 18 years ago

Last modified 16 years ago

#3062 closed defect (bug) (wontfix)

the_posts filtering should be done earlier

Reported by: coppit's profile coppit Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.0.2
Component: General Keywords:
Focuses: Cc:


the_posts can be used to remove posts from the blog. However, it is called *after* the posts for a page are computed. This means that if I happen to filter out all of the posts for a page, posts from the next page will not slide up, leaving me with a blank page and a "next page" link.

Posts should be filtered with the_posts, then the results should be split into pages.

Change History (6)

#1 @coppit
18 years ago

Also, the count for monthly archives should be computed after the_posts filtering, so that if I happen to filter out all the posts, the count should be 0, not the unfiltered count.

#2 @RuddO
18 years ago

No, not true. I just wrote a plugin that does some sort of thing like you say here. You should use the posts_where hook.

WP devs: am I right?

#3 @RuddO
18 years ago

devs: is it within bounds for me to close a bug?

#4 @westi
18 years ago

RuddO: if you feel that it is not a bug there should be no problem with closing as worksforme.

Best thing would be to attach your test plugin to show how you use post_where to achieve the required result and close as worksforme.

That way people can see how to do it.

#5 @ryan
18 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

Moving the hook will break existing expectations. posts_where is a good hook to try.

#6 @hangy
16 years ago

A problem I see with using posts_where and posts_join (e. g. to join metadata) is that several plugins using these hooks may be incompatible, for example because of bad joins. Moving the_posts is not possible for sure, but a new earlier hook could be a good thing to actually enable plugin-authors to remove posts from the array before all that information about the array is stored.

Note: See TracTickets for help on using tickets.