I have 2 post types: accounts, and dealers. I have a bi-directional relationship field setup for both of them. I have a nested table with the row being the query. I am trying to obtain the values of the custom fields in the related dealer CPT in the same query but can’t seem to figure out how to do this.
{acf_related_dealer} returns the related dealer post id, but I can’t figure out how to fetch the custom field data in this post.
I tried:
{acf_related_dealer.acf.contact_phone}
{acf_related_dealer.contact_phone}
{acf_related_dealer_contact_phone}
{acf_related_dealer_field_contact_phone}
{acf_related_dealer__contact_phone}
{acf=related_dealer:contact_phone}
{relation=related_dealer:contact_phone}
{acf_related_dealer\contact_phone}
{dealer_contact_phone}
but nothing seems to work, is this not possible natively inside bricks? this is the query I’m using:
$current_user = wp_get_current_user();
$user_roles = (array) $current_user->roles;
$query = [
'post_type' => 'account',
'nopaging' => true,
'posts_per_page' => -1,
'meta_key' => 'stage',
'orderby' => 'meta_value',
'order' => 'ASC'
];
// Role-based filtering
if (!in_array('administrator', $user_roles, true)) {
$meta_query = [];
if (in_array('oem-admin', $user_roles, true)) {
$meta_query[] = [
'key' => 'partner_tag',
'value' => 'OEM',
'compare' => 'LIKE',
];
}
if (in_array('oem-rep', $user_roles, true)) {
$first_name = strtoupper($current_user->first_name);
$last_name = strtoupper($current_user->last_name);
$final_value = "OEM-REP-{$first_name}-{$last_name}";
$meta_query[] = [
'key' => 'partner_tag',
'value' => $final_value,
'compare' => '=',
];
}
if (!empty($meta_query)) {
$meta_query['relation'] = 'OR';
$query['meta_query'] = $meta_query;
}
}
return $query;