[wp-trac] [WordPress Trac] #63600: Enhancement: Add get_pages_args filter to allow full control over get_pages() arguments before parsing in get_pages()
WordPress Trac
noreply at wordpress.org
Tue Jun 24 15:58:09 UTC 2025
#63600: Enhancement: Add get_pages_args filter to allow full control over
get_pages() arguments before parsing in get_pages()
-------------------------------------------------+-------------------------
Reporter: vincent06 | Owner: vincent06
Type: enhancement | Status: assigned
Priority: normal | Milestone: Awaiting
| Review
Component: Query | Version: 6.8
Severity: normal | Resolution:
Keywords: has-patch needs-docs reporter- | Focuses: template
feedback |
-------------------------------------------------+-------------------------
Comment (by vincent06):
Replying to [comment:5 jorbin]:
> Hi @vincent06, thanks for opening your first ticket on WordPress Core
Trac.
>
> Can you explain the use cases that you think this solves that the
existing `get_pages_query_args` filter doesn't?
Thanks for the follow-up!
The use case that prompted this enhancement is the need to modify
arguments like `child_of` or `parent` when `get_pages()` is called by core
or third-party plugins — for example, inside a `wp_dropdown_pages()`
context — but before they are parsed and used to control hierarchical
filtering.
While `get_pages_query_args` allows customization of the arguments passed
to `WP_Query`, it does not affect how `get_pages()` itself uses values
like `child_of`, `number`, `offset`, or `parent`, since those are
extracted from the original `$args` array *before* the actual
`get_pages_query_args` filter is applied. So any attempt to override them
via `get_pages_query_args` has no effect on the behavior of
`get_page_children()` or pagination or some others variable hardcoded
before.
This becomes a problem in cases like:
- A plugin calls `get_pages()` with `child_of => X`
- A filter attempts to override `child_of` to a different page ID
- The override in `get_pages_query_args` doesn't work, because `$child_of`
is already extracted and used before the filter is applied
Adding a `get_pages_args` filter (before `wp_parse_args()`) solves this
cleanly and allows full control of all inputs, just like how
`wp_list_pages()` and `shortcode_atts()` allow filtering the raw args
before processing.
It's backward-compatible, and doesn’t interfere with existing usage — it
simply opens up a new level of flexibility for developers working with
hierarchical pages.
Happy to clarify further or provide additional examples if helpful!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63600#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list