[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
Thu Jun 19 17:23:27 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 | Keywords: has-patch needs-refresh needs-docs
Focuses: template, |
performance |
--------------------------+------------------------------------------------
Currently, the get_pages() function provides the get_pages_query_args
filter to modify the arguments passed to WP_Query. However, many core
variables like child_of, number, parent, offset, and hierarchical are
extracted from the original $args array before that filter is applied —
meaning they cannot be altered using get_pages_query_args.
This limits extensibility in cases where developers want to
programmatically change the pages being queried by modifying the original
$args — such as dynamically altering child_of or parent, or injecting a
number or offset value.
To resolve this, I propose adding a new filter get_pages_args just before
the call to wp_parse_args():
{{{#!php
<?php
$args = apply_filters( 'get_pages_args', $args, $defaults );
$parsed_args = wp_parse_args( $args, $defaults );
}}}
This small addition makes it possible to modify any parameter passed to
get_pages() — including those that are later used directly, not via
WP_Query.
This approach is:
Non-breaking and backward-compatible.
Consistent with existing WordPress patterns, like the wp_parse_args usage
in other core functions.
More intuitive for developers who expect $args to be fully filterable.
Adding get_pages_args brings get_pages() in line with other WordPress
functions that allow full control over inputs, and complements
get_pages_query_args rather than replacing it.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63600>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list