#19515 closed enhancement (worksforme)
Helper functions for accessing 'tax_query', 'query', 'meta_query' WP Query properties
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Query | Version: | 3.1 |
| Severity: | minor | Keywords: | needs-patch |
| Cc: |
Description
In the current state, to access the 'tax_query', 'query', 'meta_query', we must do so via the global $wp_query. It would be useful have access to these properties via getters, similar to get_queried_object or get_query_var.
Example use case: Having a second loop on a page displaying a filtered or adjusted version of the main loop.
Change History (4)
comment:1
ejdanderson
— 19 months ago
- Severity changed from normal to minor
comment:2
follow-up:
↓ 3
scribu
— 19 months ago
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from new to closed
- Type changed from feature request to enhancement
comment:3
in reply to:
↑ 2
ejdanderson
— 19 months ago
Replying to scribu:
The tax_query property is accessible from any WP_Query instance:
$my_query = new WP_Query( array( 'tax_query' => array( ... ) ) ); var_dump( $my_query->tax_query );
Yes, but we could also do that with the get_queried_object. get_query_var, have_comments etc.. methods, which are just wrappers for the global $wp_query object methods. Is it because these are properties and not methods?
The tax_query property is accessible from any WP_Query instance:
$my_query = new WP_Query( array( 'tax_query' => array( ... ) ) ); var_dump( $my_query->tax_query );