Wordpress - Change The Title Of a Meta Box

Improved Answer

I've decided to revisit this question after realising how unnecesarily hacky it is.

The the best solution is to to remove the metabox, and then re-add it, specifying an alternative title. Here's an example for the post post-type.

add_action( 'add_meta_boxes_post',  'wpse39446_add_meta_boxes' );
function wpse39446_add_meta_boxes() {
    remove_meta_box( 'authordiv', 'post', 'core' );
    add_meta_box( 'authordiv', __('Team Member','wpse39446_domain'), 'post_author_meta_box', 'post', 'core', 'high' );
}

Note: If you are doing this for a non-core metabox, you'll need to ensure the callback is called after the metabox is added by specifying a higher priority.


So, $wp_meta_boxes has a lot of nested arrays

For your purposes:

$wp_meta_boxes['post_type']['normal']['core']['authordiv']['title']= 'teams';

(NB. I'm not sure if any arguments are passed to that action...:

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
}

Actually the array structure is more complicated. I've updated my code. I've tested this and it works :D (Just make sure you change 'post_type' to the post type, e.g. 'post').

Loosely the structure of the array is post-type > priority > core > metabox ID.

If you want to see the array for yourself, inside your function use:

echo '<pre>';
print_r($wp_meta_boxes);
echo '</pre>';
wp_die('');

I know this is an old question, but there is a filter hook for this. You would add to your theme's functions.php or custom functionality plugin a function hooked to post_type_labels_{$post_type}

Take for example that we have a custom post type called band and we want to change the featured image labels to "Band Photo". The function would look something like this:

function wpse39446_modify_featured_image_labels( $labels ) {
  $labels->featured_image = __( 'Band Photo', 'textdomain' );
  $labels->set_featured_image = __( 'Set Band Photo', 'textdomain' );
  $labels->remove_featured_image = __( 'Remove Band Photo', 'textdomain' );
  $labels->use_featured_image = __( 'Use as Band Photo', 'textdomain' );

  return $labels;
}
add_filter( 'post_type_labels_band', 'wpse39446_modify_featured_image_labels', 10, 1 );

ref: https://developer.wordpress.org/reference/hooks/post_type_labels_post_type/

Tags:

Metabox