This might might be more of a PHP question – but does deal with a WordPress plugin, Advanced Custom Fields
I am using a global select option to store a specific Location (custom post type) as the headquarters. I am storing the value as such:
function options_headquarters() {
foreach(get_field('option_headquarters','options') as $post_object) {
$options_headquarters = $post_object->ID;
return $options_headquarters;
}
}
What I am fuzzy on is – since my option is only allowed to grab one value — is there an alternative to using a foreach statement (to grab just a specific array value) and still applying it to the post_object?
That function stores the postID of that Location. I am currently outputting this in my template as:
echo get_field('location_phone',options_headquarters());
which grabs a field called location_phone
(a meta value within the Location custom post type) and specify a specific postID to grab the value from (the headquarters). Is there a better way of handling passing in this headquarters value? Just pulling this out of you know where, but something like options_headquarters('location_phone');
would be pretty sweet 😉
Thanks!
This ended up working for me: