Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#55444 closed defect (bug) (duplicate)

Sticky posts are limited to 5

Reported by: spacedmonkey's profile spacedmonkey Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: reporter-feedback
Focuses: Cc:


The call to get sticky posts in WP_Query uses get_posts. As no limit is sent, the default limit to 5 posts. This means, that is the site has 15 sticky posts, only 5 sticky posts will ever be shown on the front end.

Change History (4)

#1 @spacedmonkey
2 years ago

  • Keywords needs-patch good-first-bug added

#2 @azouamauriac
2 years ago

  • Keywords reporter-feedback added

Hello @spacedmonkey what are the steps to reproduce the bug please? I created six posts and made all of them sticky, I created a block page, use query loop to show only stickies posts and then I go to front page and all my six stickies posts are shown up.

Also I made request like below and I get all my six stickies posts


$args = array(
        'post_type' => 'post',
        'post__in' => get_option( 'sticky_posts' )

$the_query = new WP_Query($args);

So how can I reproduce the bug here? Thanks.

Last edited 2 years ago by azouamauriac (previous) (diff)

#3 @SergeyBiryukov
2 years ago

I have reproduced the issue with these steps:

  1. Switch the theme to Twenty Twenty-One, as Twenty Twenty-Two seems to ignore sticky posts for some reason.
  2. Create 10 sticky posts.
  3. Create 10 non-sticky posts.
  4. On the home page, there are now 10 non-sticky posts and 5 sticky posts (instead of 10).

It looks like this was introduced in [52982] / #36907 as a result of removing the 'nopaging' => true argument from the get_posts() call in question. It's not quite clear why it was removed, as neither the ticket nor the commit message mention the removal. With 'nopaging' => true restored, all 10 sticky posts are displayed as expected.

This seems like a backward compatibility break, so I have reopened #36907 with a patch.

Last edited 2 years ago by SergeyBiryukov (previous) (diff)

#4 @SergeyBiryukov
2 years ago

  • Keywords needs-patch good-first-bug removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Let's continue in #36907 to avoid confusion.

Note: See TracTickets for help on using tickets.