How to change the text of the “Publish” button to “Save” in WordPress?

To change the text of the “Publish” button to “Save” in WordPress, you can use the following code snippet:

function change_publish_button_text($translation, $text) {
    if ($text === 'Publish') {
        return 'Save';
    }
    return $translation;
}
add_filter('gettext', 'change_publish_button_text', 10, 2);

You can add this code to your theme’s functions.php file or in a custom plugin file.

This code defines a function change_publish_button_text that checks if the $text parameter is equal to 'Publish'. If it is, it returns 'Save', effectively changing the text of the button. If the text does not match 'Publish', it returns the original translation.

The add_filter() function hooks into the gettext filter, which is responsible for translating text strings in WordPress. By adding our filter, we can intercept the translation process and modify the text of the “Publish” button to “Save”.

After adding this code and saving the changes, the text of the “Publish” button should be changed to “Save” throughout your WordPress site.

Similar Posts