Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#10549 closed defect (bug) (wontfix)

Sticky not working with query_posts()

Reported by: kingjeffrey's profile kingjeffrey Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.8.1
Component: General Keywords: query_posts, sticky
Focuses: Cc:

Description

Sticky posts do not always float to the top when using query_posts().

Things work as expected in this simple case:
query_posts('showposts=9');

But sticky posts cease to work as soon as you filter by category_name, like this:
query_posts('category_name=portfolio&showposts=9');

Change History (4)

#1 @kingjeffrey
15 years ago

It appears that even query_posts('showposts=9'); returns unexpected results. While sticky posts do rise to the top, the number of posts returned is 9 plus the sticky count.

#2 @nacin
15 years ago

  • Milestone Unassigned deleted
  • Resolution set to worksforme
  • Status changed from new to closed

You can exclude sticky posts being prepended via caller_get_posts = 1.

http://codex.wordpress.org/Template_Tags/query_posts

#3 @kingjeffrey
15 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

@nacin

Thank you. I am aware of that, but it does not address my issue.

Sticky posts do not work with query_posts('category_name=portfolio&showposts=9'); (regardless of the caller_get_posts setting.

Also, if sticky posts exist, query_posts('showposts=9'); does not return 9 posts (as would be reasonable to expect). It returns 9 non-sticky posts _plus_ all sticky posts

#4 @ryan
15 years ago

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

Sticky posts are included only for the front page and do not count against the total. This is by design.

Note: See TracTickets for help on using tickets.