Skip to content

Sticky Post does not work correctly with loop (2 issues!) #80624

Open

Description

@iritfab

Description

I have 12 posts in my loop as a 4x3 grid.

So far (including 7.0.1) it worked as expected:
first page: 1 sticky, 11 posts (newest first)
second page: 12 posts and so on
sticky post with an elder date did not appear on page 2

With 7.0.2:
first page: sticky post, 12 posts
second page: 12 posts but again the sticky post (so it appears twice)

I do not use anything special, Theme Abisko and the loop ist simply "standard" as in the theme

Step-by-step reproduction instructions

Wordpress 7.0.2, Theme Absiko, use out of the box and make a sticky post to see this strange behaviour

I have only my prod page

Screenshots, screen recording, code snippet

No response

Environment info

Wordpress 7.0.2 DE
Theme Abisko from Anders Noren

Browser: Chrome and Firefox

Device: Macbook Air 2026 and iPhone 17

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Activity

  1. added
    [Type] BugAn existing feature does not function as intended
    on Jul 23, 2026
  2. wdjina commented on Jul 23, 2026

    @wdjina

    The sticky post does not remain at the top of the posts list as expected. Instead, it is listed as a normal post according to its publish date rather than being displayed at the top of the loop.

    === Environment

    • WordPress: 7.1-beta3, 7.0.2, 7.0
    • PHP: 8.2.29
    • Theme: Twenty Twenty-Five
    • Plugins:
      • Gutenberg 23.6.0
      • Query Monitor 4.0.7
      • WordPress Beta Tester 4.0.0

    === Steps to Reproduce

    1. Created few dummy post with different dates. Had 10 post per page.
    2. Made one of the post as a sticky post.
    3. Moved from one page to another.

    === Expected Results
    The sticky post must be at the top of the list.

    === Actual Results
    It is listed as a normal post.

    Image
  3. iritfab commented on Jul 23, 2026

    @iritfab
    Author

    can you please check if you have also one post more on the first page (as in my example 13 instead of 12), because the sticky post is somehow not counted.

  4. Swanand01 commented on Jul 27, 2026

    @Swanand01
    Contributor

    For me the sticky post does appear at the top as the first post on both pages. The weird part is it is not considered as one of the 12 items set as the "Items per page"

    Environment:
    WP: 7.1-alpha-62569
    Theme: Twenty Twenty-Five

    Editor:
    Image

    Frontend page 1 Frontend page 2
    Image Image
  5. github-actions commented on Aug 27, 2026

    @github-actions

    Hi,
    This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps.
    Thanks for helping out.

  6. added
    [Status] StaleGives the original author opportunity to update before closing. Can be reopened as needed.
    on Aug 27, 2026
  7. iritfab commented on Aug 27, 2026

    @iritfab
    Author

    This still does not work correctly, issue not solved with newer versions

  8. removed
    [Status] StaleGives the original author opportunity to update before closing. Can be reopened as needed.
    on Aug 28, 2026
  9. github-actions commented on Sep 28, 2026

    @github-actions

    Hi,
    This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps.
    Thanks for helping out.

  10. added
    [Status] StaleGives the original author opportunity to update before closing. Can be reopened as needed.
    on Sep 28, 2026
  11. iritfab commented on Sep 28, 2026

    @iritfab
    Author

    This still does not work correctly, issue not solved with newer versions

  12. Vrishabhsk commented on Sep 28, 2026

    @Vrishabhsk
    Contributor

    hi @iritfab @wdjina

    Let me know your thoughts on it. Thanks

  13. removed
    [Status] StaleGives the original author opportunity to update before closing. Can be reopened as needed.
    on Sep 29, 2026
  14. robelsust commented on Oct 7, 2026

    @robelsust

    Test & Review Report

    Tested the reproduction steps and PR #83604 locally against WordPress trunk.

    Environment

    Reproduction (Before Fix)

    1. Created 8 sequential posts and marked the oldest post as Sticky.
    2. Inserted a Query Loop block with perPage = 3.
    3. Page 1: Returns 4 posts ([Sticky Post 1, Post 8, Post 7, Post 6]) — sticky post is prepended as expected.
    4. Page 2: Returns 4 posts ([Sticky Post 1, Post 5, Post 4, Post 3]) — Bug confirmed: Sticky post is repeated at the top of Page 2, and the page exceeds the 3 items limit.

    Verification (After PR #83604)

    1. Page 1: Returns 4 posts ([Sticky Post 1, Post 8, Post 7, Post 6]).
    2. Page 2: Returns exactly 3 posts ([Post 5, Post 4, Post 3]) — Fix confirmed: Sticky post is excluded from page 2 and only appears on page 1.

    Root Cause & Core Alignment

    build_query_vars_from_query_block() paginated custom queries using only offset, leaving paged unset. WP_Query defaults $page = 1 when paged is omitted, causing $page <= 1 to evaluate to true on all paginated requests and prepending sticky posts to every page.

    Setting paged in the query_loop_block_query_vars filter in PR #83604 cleanly resolves this and aligns with WordPress Core PR WordPress/wordpress-develop#8750 (Trac #63365).

    LGTM!

  15. iritfab commented on Oct 7, 2026

    @iritfab
    Author

    I was not able to test the solution (sorry, no developer - I am kind of advanced user). But this sounds good.

  16. Dibyajyotikabi commented on Oct 15, 2026

    @Dibyajyotikabi

    Reproduced both problems on WP 7.1.3 + Gutenberg 24.2.0 (Twenty Twenty-Five, Chrome 154 on Linux).

    Setup: Query Loop not inheriting the query, 4 per page, newest first, sticky posts set to Include, one older post marked sticky.

    • The sticky post shows at the top of page 1 and again at the top of page 2 (?query-1-page=2).
    • Every page shows 5 posts instead of 4. The sticky post isn't counted against the per-page limit.

    Happy to test #83604 against the same setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TestingNeeds further testing to be confirmed.[Block] Query LoopAffects the Query Loop Block[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions