How to Change “Set Featured Image” Text in WordPress Admin Panel

Home » Snippets » How to Change “Set Featured Image” Text in WordPress Admin Panel

Created with:



Creator: WPTurbo Team

Customize with WPTurbo AI

Add Snippet To Project

New Project
Add To Existing Project

Are you tired of the default "Set Featured Image" text in your WordPress admin panel? Maybe you want to change it to something more specific to your site or brand. Whatever your reason, it’s actually quite simple to do with just a few lines of code. In this article, we’ll show you how to easily customize the text for your Featured Image button.

					function wpturbo_change_featured_image_text( $content ) {
    $content = str_replace( __( 'Set featured image' ), __( 'Change featured image' ), $content );
    return $content;
add_filter( 'admin_post_thumbnail_html', 'wpturbo_change_featured_image_text' );

The purpose of this code snippet is to change the label of the "Set featured image" button in the WordPress admin dashboard to "Change featured image". This can be useful if you want to provide clearer instructions to your users or if you want to customize the admin interface to match your site’s branding.

Firstly, we define a new function called wpturbo_change_featured_image_text(). This function takes a string as a parameter, which represents the HTML content of the "Set featured image" button.

Inside the function, we use the PHP str_replace() function to replace the original label with the new label. The first parameter of str_replace() is the original label, which is wrapped in a WordPress __() function to make it translatable. The second parameter is the new label, which is also wrapped in a __() function for the same reason.

The last step is to hook the wpturbo_change_featured_image_text() function into the admin_post_thumbnail_html filter using the add_filter() function. This filter is applied to the HTML output of the featured image meta box in the WordPress post editing screen. Therefore, the wpturbo_change_featured_image_text() function will modify the HTML output of the "Set featured image" button every time the post editing screen is rendered.

Register an account to save your snippets or go Pro to get more features.