Skip to content

Blocks Query Pagination

github-actions[bot] edited this page Apr 26, 2026 · 1 revision

Query Pagination Block

Block name: designsetgo/query-pagination Added in: 2.1.0 Category: DesignSetGo


Block family: Query (parent) · Query Results · Query Pagination · Query Filter · Query Group Header · No Results


Overview

The Query Pagination block adds page navigation to a Dynamic Query. It reads the total page count from the parent query's render state and emits the appropriate navigation controls. It is placed as a sibling of the Query Results block, inside a designsetgo/query parent, and can appear anywhere in the block tree — before or after the results.

The block supports three navigation modes and automatically hides itself when the query fits on one page.


Block Attributes

Attribute Type Default Notes
paginationKind string "numbered" numbered | loadmore | infinite
labelLoadMore string "" Button label for load-more; defaults to "Load more"
labelLoading string "" Button label while loading; defaults to "Loading…"
buttonLabelWhenPaused string "Load more" Button label shown after infinite scroll auto-pauses
showPrevNext boolean true Show previous/next links in numbered mode
autoPauseAfter number 3 Number of automatic infinite-scroll loads before showing the manual button
sentinelOffsetPx number 200 How many pixels before the sentinel enters the viewport to trigger a load
alignment string "left" left | center | right — horizontal alignment of pagination controls

The mode attribute is a legacy alias for paginationKind. New blocks use paginationKind.


Pagination Modes

Numbered

Emits a <nav> with an accessible unordered list of page links generated by paginate_links(). Previous and next links are included when showPrevNext is true.

Markup class: dsgo-query-pagination--numbered

Load more

Renders a single button that appends the next page of results when clicked. The Interactivity API (actions.loadMore) fetches the next page from POST /designsetgo/v1/query/render, appends the new items to the existing grid, and updates the aria-live result count. Focus moves to the first new item after each load. When the last page is reached the button is removed from the DOM.

Markup class: dsgo-query-pagination--loadmore

Infinite scroll

Combines automatic loading with a manual fallback button. An IntersectionObserver watches a sentinel <div> placed after the item grid. When the sentinel enters the viewport, the hidden fallback button is programmatically clicked, which triggers the same actions.loadMore path as load-more mode.

Automatic loading pauses after autoPauseAfter loads (default 3). At that point the previously hidden button becomes visible so the user can continue manually. This prevents runaway infinite scrolling on long result sets.

prefers-reduced-motion support: when the user has enabled reduced-motion at the OS level, the IntersectionObserver is never set up and the manual button is shown immediately, maintaining full functionality without automatic motion.

Markup class: dsgo-query-pagination--infinite


Inspector Controls

Pagination kind — select between Numbered, Load more, and Infinite scroll.

Alignment — left, center, or right alignment for the pagination control.

Show previous/next — toggle for numbered mode; adds ‹ Previous / Next › links.

Load more label — the button text in load-more and the paused-state label in infinite scroll.

Loading label — text shown on the button while a request is in flight.

Auto-pause after — infinite scroll only; number of auto-loads before the manual button appears.

Sentinel offset — infinite scroll only; margin in pixels before the viewport edge at which loading triggers.


Native Block Bindings

The following attributes are exposed via the WordPress 6.9 Block Bindings API (registered in class-block-bindings-support.php), meaning they can be driven by any Block Bindings source via the editor's Connections panel:

  • labelLoadMore
  • labelLoading
  • buttonLabelWhenPaused

This lets editors connect button labels to post meta or custom sources without custom code — useful for multilingual setups or personalized CTAs.


Frontend Behavior

  • Numbered: standard server-side pagination via WordPress query vars (paged / page)
  • Load more and infinite: AJAX via POST /designsetgo/v1/query/render; the response is appended to the existing grid without a page reload; the browser URL does not change
  • Filter changes triggered by the Query Filter block reset pagination back to page 1 automatically
  • The block emits nothing when totalPages < 2

Accessibility

  • Numbered pagination is wrapped in <nav role="navigation" aria-label="Query pagination">
  • Load-more button carries aria-busy="true" and the loading label while a request is in flight
  • After new items are appended, focus moves to the first new item; if the item element has no naturally focusable child, a temporary tabindex="-1" is applied and removed on blur
  • Infinite scroll without reduced-motion: manual button starts hidden and becomes visible only after auto-pause; keyboard and screen-reader users always have a button available
  • Infinite scroll with prefers-reduced-motion: manual button is visible from the start; no automatic loading

Related Blocks


Auto-generated from docs/blocks/QUERY-PAGINATION.md. To update, edit the source file and changes will sync on next push to main.

Home

Getting Started

Blocks

Extensions

API Reference

Development Guides

Patterns

Compliance

Formats

Testing

Troubleshooting

Audits

Plans

Reviews


GitHub | Report Issue

Clone this wiki locally