Speakers::get_speakers( array $attr, array $speaker_ids )
Fetches the specified speakers based on the provided attributes.
Parameters
- $attr
-
(array) (Required) Array of attributes from shortcode.
- $speaker_ids
-
(array) (Required) Array of speaker IDs.
Return
(WP_Query) The query object containing the specified speakers.
Source
File: src/Conference/Views/Shortcode/Speakers.php
public function get_speakers( $attr, $speaker_ids ) {
// Fetch all specified speakers.
$speaker_args = [
'post_type' => Plugin::SPEAKER_POSTTYPE,
'posts_per_page' => (int) $attr['posts_per_page'],
'orderby' => $attr['orderby'],
'order' => $attr['order'],
];
if ( ! empty( $attr['track'] ) ) {
$speaker_args['post__in'] = empty( $speaker_ids ) ? [ 0 ] : $speaker_ids;
}
// phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_tax_query
if ( ! empty( $attr['groups'] ) ) {
$speaker_args['tax_query'] = [
[
'taxonomy' => Plugin::GROUP_TAXONOMY,
'field' => 'slug',
'terms' => $attr['groups'],
],
];
}
// phpcs:enable WordPress.DB.SlowDBQuery.slow_db_query_tax_query
return new WP_Query( $speaker_args );
}
Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |