Skip to content

Anchor option for pagination in the Query Loop Block #50137

Closed

Description

@AdamWarnock-UA

This is splitting the issues brought up in #48330 into two different ones.

What problem does this address?

When using pagination to navigate through the pages in a Query Loop block, the page reloads and moves the user back to the top of the page. This is a user experience issue.

What is your proposed solution?

Provide a toggle that, when active, tells WordPress to append an anchor ID to the pagination links. The toggle would be inactive by default which would not change the output of the block. This should, hopefully, allow existing custom solutions that modify the block's output to continue working.

When the toggle is active, default behavior would be to generate a unique anchor ID for the block based on post type, filters, and where it appears on the page. This anchor ID is then appended to the pagination links in the block. If the user wishes to use a custom anchor ID, they should be able to edit the block anchor ID and the anchor ID that's appended to the pagination code in their own fields.

Activity

  1. added
    [Block] Query Loop
    [Type] Bug
    Needs Testing
    on Apr 28, 2023
  2. added
    [Type] Enhancement
    [Block] Query Pagination
    and removed
    [Type] Bug
    Needs Testing
    [Block] Query Loop
    on May 2, 2023
  3. masperber commented on Mar 24, 2024

    @masperber

    +1

  4. ellatrix commented on Nov 4, 2026

    @ellatrix
    Member

    Tested on trunk: the Query Loop block now has a per-block opt-in that keeps visitors at the block when they page through it. It's the Reload full page toggle under Advanced, added in #53812 and renamed in #65081. When it's off, the pagination links load the next page of posts in place, with no full page reload, so the page doesn't jump back to the top.

    Reload full page toggle off

    Test page: a 1500px spacer, then a Query Loop showing 1 post per page.

    With Reload full page off, I scrolled down and clicked "Next Page". Page 2 loads in place, the URL updates, and the view stays at the Query Loop:

    reload-off-stays-at-query.webm

    With it on (the default), the same click reloads the page and lands at the top:

    reload-on-back-at-top.webm

    It isn't the anchor link the issue suggested, but it fixes what the issue describes (the jump back to the top) the same opt-in way. One limit: if the Query Loop has blocks that don't support it, such as some third-party blocks, the editor turns full reload back on and shows a notice.

    Closing as done. If you need the anchor version specifically, for example for links shared from page 2, please say so and we can reopen.

    Partly automated with help from Claude.

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

    [Block] Query Pagination[Type] Enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions