You’re already storing the venue, so you should be able to simply extract from an array front-side based on what a get_post_meta
call returns. If i’m following you correctly still at this point, something along these lines should do the trick.
function get_related_event_data( $venue, $field = 'all' ) {
$event_data = array(
'Spruce Gallery' => array(
'address' => '',
'phone_no' => '',
'url' => ''
),
'Pine Gallery' => array(
'address' => '',
'phone_no' => '',
'url' => ''
),
'Oak Gallery' => array(
'address' => '',
'phone_no' => '',
'url' => ''
),
);
if( !isset( $event_data[$venue] ) )
return;
// Optionally return all fields(note: you can't echo arrays, so be sure to loop over the data if pulling all fields
if( 'all' == $field )
return $event_data[$venue];
if( !isset( $event_data[$venue][$field] ) )
return;
return $event_data[$venue][$field];
}
You then pass your meta value into that function to extract the data related to the venue, eg.
$venue = get_post_meta( $post->ID, 'YOURPREFIX_event_venue', true );
echo get_related_event_data( $venue, 'address' );
NOTE: I have no idea how $prefix
is defined in your code, so you’d need to replace YOURPREFIX_
with the appropriate prefix(as per your existing code).
If i’ve not quite followed what you were asking correctly, please do try to clarify what you’re aiming for..
Hope that helps.. 🙂