unsplash-logo Sneha Chekuri

How to Change the Featured Image Labels

Published 2015-11-03

When creating a site for a client or creating a plugin, I’ve found its helpful to customize things as much as possible to the intended usage. This is especially important for client work since most clients have specific terminology they use for things. In the case of Featured Images, the site or plugin might be using the featured image differently than how one might use it on a news or blog post.

I’m currently writing a plugin with a custom post type and using the featured image as a headshot for an employee. While “featured image” may work fine, “headshot” is more specific and makes more sense in this context. I haven’t been able to find anything recent about how to change the labels on the existing Featured Image metabox. The most commonly referenced code only works some of the time. Specifically, when one removes a featured image, the label for the link changes back to referencing “featured image” instead of the customized label.

I dug through the core and found the posttype_labels$post_type filter, which was added in version 3.5. This filter makes customizing the featured image labels super easy:

 * Changes strings referencing Featured Images for a post type
 * In this example, the post type in the filter name is "employee"
 * and the new reference in the labels is "headshot".
 * @see
 * @param     object    $labels    Current post type labels
 * @return    object               Modified post type labels
function change_featured_image_labels($labels) {
    $labels->featured_image = 'Headshot';
    $labels->set_featured_image = 'Set headshot';
    $labels->remove_featured_image = 'Remove headshot';
    $labels->use_featured_image = 'Use as headshot';

    return $labels;
} // change_featured_image_labels()

add_filter('post_type_labels_employee', 'change_featured_image_labels', 10, 1);

Gist of the code above

The labels are in an object and we then reset the values of each specific item to what we want. Then return the object.

Share this post!

Check out these most recent posts:

How to Add a Class to a Metabox

Toggling the visibility of a metabox using a form requires the metabox to have a custom class. This is how to add custom classes to a metabox.

ArtistDataPress Expiration

In case you haven't heard, ArtistData is shutting down, so the ArtistDataPress plugin will also be shutting down as of October 14.

Avoiding get_theme_mod Errors

If you're getting an error related to the get_theme_mod function, the solution is simpler than you think. Check out this solution.