Make WordPress Core

Opened 4 months ago

Last modified 2 weeks ago

#64608 new enhancement

Add support for Terms Query Pagination blocks

Reported by: jillro's profile jillro Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch changes-requested
Focuses: Cc:

Description

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

Change History (4)

This ticket was mentioned in PR #10872 on WordPress/wordpress-develop by @jillro.


4 months ago
#1

Adds build_terms_query_vars_from_block() and terms_query_register_query_vars() to wp-includes/blocks.php to support pagination in the Terms Query block.

These helper functions are used by:

  • The updated Term Template block (which now supports paginated term results via the termspage query variable)
  • The new Terms Query Pagination blocks (core/terms-query-pagination, core/terms-query-pagination-next, core/terms-query-pagination-previous, core/terms-query-pagination-numbers)

build_terms_query_vars_from_block() extracts and normalizes query arguments from the block context, handling both inherited (taxonomy archive) and custom term queries. It follows the same pattern as the existing build_query_vars_from_query_block() and build_comment_query_vars_from_block().

terms_query_register_query_vars() registers termspage as a public query variable so it can be used for pagination URLs.

The block files themselves (block.json, index.php, CSS, JS) are synced automatically via the Gutenberg build process.

#2 @audrasjb
4 weeks ago

Removing trunk version as this is not going to be shipped with WP 7.0 but in the next releases.

#3 @desrosj
4 weeks ago

  • Keywords changes-requested added
  • Summary changed from Backport: Add Terms Query Pagination blocks to Add support for Terms Query Pagination blocks
  • Version trunk deleted

Since this is an enhancement, there's no first version of WordPress this can be reproduced in. Removing trunk version.

@jillro Thanks for opening PRs for both code bases! At quick glance, the version within the @since annotations will need to be bumped to 7.1.0 now. It's possible some more changes will be required, so worth refreshing both PRs so that they're ready for consideration with 7.0 being released in the next 24 hours.

Just linking to the corresponding Gutenberg PR for easy reference.

#4 @jillro
2 weeks ago

Thanks @desrosj, I've bumped the @since annotations to 7.1.0 in both PRs and refreshed Gutenberg PR against trunk.

One change worth noting on the core side: the termspage query variable is no longer registered via a query_vars filter helper. It's now added straight to WP::$public_query_vars in wp-includes/class-wp.php, with coverage added in tests/phpunit/tests/query/vars.php.

Both PRs should be ready for another look for 7.1.0 consideration. Happy to make any further adjustments.

Note: See TracTickets for help on using tickets.