1

I am trying to change the text of the publish button to save

function change_publish_button( $translation, $text ) {

    if ( $text == 'Publish' )
        return 'Save';

    return $translation;
}

add_filter( 'gettext', 'change_publish_button', 10, 2 );

I am trying to run the above code but it doesn't change the text of the publish button, can anyone please tell what is wrong with this code or suggest any new method. Thanks in advance

Update I want to change the publish button shown in the figure below. enter image description here

  • The original text has a "..." after it, so $text isn't Publish. – Jacob Peattie Feb 6 '19 at 6:48
  • @JacobPeattie Even after changing it to "..." it doesn't work. – Mohit Nihalani Feb 6 '19 at 7:18
  • 1
    It's probably a single ellipsis character. Just inspect it in the browser and copy the exact text. – Jacob Peattie Feb 6 '19 at 8:22
0

Put below code into your theme functions.php and try

function change_publish_button( $translation, $text ) {

    if ( $text == 'Publish...' )     // Your button text
        $text = 'Save';

    return $text;
}

add_filter( 'gettext', 'change_publish_button', 10, 2 );

This one is worked for me

enter image description here

Hope it will help you!

-1

Try this:

function translate_publish( $translated_text, $untranslated_text, $domain ) {
    if( stripos( $untranslated_text, 'Publish' ) !== FALSE ) {
        $translated_text = str_ireplace( 'Publish', 'Save', $untranslated_text ) ;
    }
    return $translated_text;
}
if(is_admin()){
    add_filter( 'gettext', 'translate_publish', 99, 3 );
}
  • it does work for the publish to save on the list of posts under the date option but it doesn't change the text of the button. – Mohit Nihalani Feb 6 '19 at 5:28
  • Which other button are you talking about? – Lucien Dubois Feb 6 '19 at 5:35
  • I have updated the image, the publish button which is next to the preview button – Mohit Nihalani Feb 6 '19 at 5:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.