Skip to content

Add Terms Query Pagination blocks#74545

Open
jillro wants to merge 3 commits intoWordPress:trunkfrom
jillro:add/terms-query-pagination
Open

Add Terms Query Pagination blocks#74545
jillro wants to merge 3 commits intoWordPress:trunkfrom
jillro:add/terms-query-pagination

Conversation

@jillro
Copy link
Copy Markdown
Contributor

@jillro jillro commented Jan 12, 2026

What?

Introduce new blocks to enable pagination for terms queries, including "Previous", "Next", and "Page Numbers" links.

Why?

Terms query was introduced in 6.9. There is many use case were someone may use pagination on a term query, for example with a "Magazine Issue" taxonomy. See #73751.

How?

Add terms-query-pagination and corresponding previous, next and numbers blocks, as well as a termspage query var.

Testing Instructions

  • Add 6 tags to any post (tags need to be non-empty).
  • Create a page.
  • Add the Terms Query block, limit the number of displayed terms to 2.
  • Select the Terms Query block in the tree, and add the Terms Query Pagination block
  • Save, and visit the page

Screenshots

image

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 12, 2026

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: [Package] Block library.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions
Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions github-actions bot added the [Package] Block library /packages/block-library label Jan 12, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 12, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jillro <jillro@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@fabiankaegy
Copy link
Copy Markdown
Member

I haven't looked at the code deeply here. But can we not achieve this by refactoring the existing jerky pagination blocks rather than creating full duplicates of it?

@jillro jillro marked this pull request as draft January 12, 2026 13:50
@jillro
Copy link
Copy Markdown
Contributor Author

jillro commented Jan 15, 2026

@fabiankaegy I considered this option, but went with a separate block, because most of the code of both blocks are branch conditions on the query, and there is little in common between a post query and a term query.

For example, query-pagination has to handle the global $wp_query; case, which is not necessary for Terms Query which is always provided by context. On the other hand, WP_Query handles part of the pagination logic (calculating max page, for example) which WP_Term_Query does not provides, so the pagination block has to do it itself.

If the display logic of numbers and previous / next is common, it seems to me it is only a very small part of the code, and I'm not sure if it would be worth the complexity of factorizing it.

@jillro jillro marked this pull request as ready for review January 15, 2026 16:38
@jillro jillro marked this pull request as draft January 15, 2026 16:39
@jillro jillro force-pushed the add/terms-query-pagination branch from 4f06c89 to 7b8e6b9 Compare January 23, 2026 14:17
Introduce new blocks to enable pagination for terms queries, including "Previous", "Next", and "Page Numbers" links.
@jillro jillro force-pushed the add/terms-query-pagination branch from 7b8e6b9 to 2380c40 Compare January 30, 2026 16:21
@jillro jillro marked this pull request as ready for review January 30, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block library /packages/block-library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants