#19515 closed enhancement (worksforme)
Helper functions for accessing 'tax_query', 'query', 'meta_query' WP Query properties
| Reported by: | ejdanderson | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Query | Version: | 3.1 |
| Severity: | minor | Keywords: | needs-patch |
| Cc: | Focuses: |
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)
#2
follow-up:
↓ 3
@
15 years ago
- Milestone Awaiting Review
- Resolution → worksforme
- Status new → closed
- Type feature request → enhancement
#3
in reply to: ↑ 2
@
15 years 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 );