FEATURE Developing the new get_carhop_members_by_comity function to optmize reusabilty and data foramting for members of the team
This commit is contained in:
parent
d426369c14
commit
0afd5fda35
|
|
@ -323,3 +323,41 @@ function get_post_specific_type_terms($post_id)
|
|||
|
||||
return $terms;
|
||||
}
|
||||
|
||||
|
||||
function get_carhop_members_by_comity()
|
||||
{
|
||||
|
||||
switch_to_blog(1);
|
||||
|
||||
$comities_field_object = get_field_object('field_699737b48c0d2');
|
||||
$comities = $comities_field_object ? $comities_field_object['choices'] : [];
|
||||
|
||||
$members_organised_by_comity = [];
|
||||
|
||||
foreach ($comities as $comity_value => $comity_label) {
|
||||
$members_posts_for_comity[$comity_value] = new WP_Query(array(
|
||||
'post_type' => 'equipe',
|
||||
'posts_per_page' => -1,
|
||||
'meta_key' => 'last_name',
|
||||
'orderby' => 'meta_value',
|
||||
'order' => 'ASC',
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'comity',
|
||||
'value' => $comity_value,
|
||||
'compare' => 'LIKE',
|
||||
),
|
||||
),
|
||||
));
|
||||
$members_organised_by_comity[$comity_value] = array(
|
||||
'name' => $comity_value,
|
||||
'label' => $comity_label,
|
||||
'members' => array_values($members_posts_for_comity[$comity_value]->posts),
|
||||
'count' => count($members_posts_for_comity[$comity_value]->posts),
|
||||
);
|
||||
}
|
||||
|
||||
restore_current_blog();
|
||||
return $members_organised_by_comity;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user