Tribe__Tickets__Tickets::get_tickets_query_args( int|WP_Post $post_id = null )
Retrieve the Query args to fetch all the Tickets.
Contents
Parameters
- $post_id
-
(int|WP_Post) (Optional) Build the args to query only for tickets related to this post ID.
Default value: null
Return
(array)
Source
File: src/Tribe/Tickets.php
public function get_tickets_query_args( $post_id = null ) {
if ( $post_id instanceof WP_Post ) {
$post_id = $post_id->ID;
}
$args = array(
'post_type' => array( $this->ticket_object ),
'posts_per_page' => - 1,
'fields' => 'ids',
'post_status' => 'publish',
'orderby' => 'menu_order',
'order' => 'ASC',
);
if ( ! empty( $post_id ) ) {
$args['meta_query'] = array(
array(
'key' => $this->event_key,
'value' => $post_id,
'compare' => '=',
),
);
}
/**
* Filters the query arguments that will be used to fetch tickets.
*
* @since 4.8
*
* @param array $args
*/
$args = apply_filters( 'tribe_tickets_get_tickets_query_args', $args );
return $args;
}
Changelog
| Version | Description |
|---|---|
| 4.6 | Introduced. |