I'm trying to create a function that would allow me to change the title of an established meta box (i.e, change Meta Box title 'Authors' to 'Team', etc.)
I didn't want to use JS or have to unset the original meta box and re-add it.
I started off with the following as per another thread that listed the code like so:
// hook to the 'add_meta_boxes' action
add_action('add_meta_boxes', 'change_meta_box_titles');
function change_meta_box_titles($post_type, $post)) {
global $wp_meta_boxes; // array of defined meta boxes
// cycle through the array, change the titles you want
}
I'm stuck on the part to "cycle through the array and change the titles you want".
What would be the best way to accomplish this? Using a foreach to loop? Or a Switch/Case scenario? I'm fairly new at this, could anyone provide an example of how to accomplish this?
Update: Stephen Harris's example does work for Core Meta's (thanks!):
add_action('add_meta_boxes', 'change_meta_box_titles');
function change_meta_box_titles() {
global $wp_meta_boxes; // array of defined meta boxes
// cycle through the array, change the titles you want
$wp_meta_boxes['post']['normal']['core']['authordiv']['title']= 'Team Member';
}
Update: Fixed For Custom Meta's
To get this to work with your custom meta's change your add_action as follows so that it fires your change title code after the meta box has been added:
add_action('add_meta_boxes', 'change_meta_box_titles', 999);