Get FAST WordPress Support
World’s Fastest WordPress Support Since 2009  
Go Up  SERVICES  CHAT LIVE  
Change Any WordPress Text On Entire Site

Change any WordPress Text on Entire Site

Be sure to change the 2 items “ORIGINAL TEXT” and “NEW TEXT” to your desire.

/* Change Text Site Wide */

function wpfi_change_text( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'ORIGINAL TEXT' :
            $translated_text = __( 'NEW TEXT' );
            break;
    }
    return $translated_text;
}

add_filter( 'gettext', 'wpfi_change_text', 20, 3 );

The “NEW TEXT” will also accept HTML so you can get really creative with this.

Enjoy THIS Change any WordPress Text Snippet

25 Comments

  • can you do this more than once because when I try to add it again in the functions it makes the whole wordpress page blank, works fine if done once? thoughts?

    Reply
    • You must change the function name if you do it twice. A WP function can not have the same name as another WP function.

      Reply
    • Yes you can, if you create an IF for every new text.
      Like this:

      add_filter( ‘gettext’, ‘wpfi_change_text’, 20 );
      function wpfi_change_text( $translated_text ) {
      if ( $translated_text == ‘ORIGINAL TEXT1’ ) {
      $translated_text = ‘NEW TEXT1’;
      }
      if ( $translated_text == ‘ORIGINAL TEXT2’ ) {
      $translated_text = ‘NEW TEXT2’;
      }
      if ( $translated_text == ‘ORIGINAL TEXT3’ ) {
      $translated_text = ‘NEW TEXT3’;
      }
      if ( $translated_text == ‘ORIGINAL TEXT4’ ) {
      $translated_text = ‘NEW TEXT4’;
      }

      return $translated_text;
      }

      Reply
  • Great snippet!
    However, it does not work everywhere.
    I’m trying to fix an issue with woocommerce checkout field errors, and this snippet doesen’t affect these texts.
    Is there any way to use a snippet to change field error messages as well?

    Reply
  • Nice little snippet, thank you, I’ve used it on a theme that kept changing the copyright text to the default text each time I saved the options.

    How about making this work on Dashboard only? Will this be possible?

    Reply
  • this would be better as a plugin so that if the template or site gets updated it doesnt erase the code snippet

    Reply
    • There are already many plugins that do this. This is another way that is simple and not plugin or database entries needed.

      Reply
    • Fantastic snippet, and a great idea, as a plugin and thats what we needed to do for a tonne of sites that use the same template, we just turned it into a plugin file (just copy hello dolly plugin layout) and each site could have is own translations for custom theme sections – make sure to encompass all translatable strings in

      Reply
  • Hi guys! For some reason this is not accepting HTML anymore. Trying to replace the text “No order has been made yet.” within WooCommerce’s My Account Orders tab (my-account/orders/) and it won’t render the HTML.

    Any suggestions?

    Thank you in advance!

    Reply
    • Hard to say without seeing files and having access. Just edit WooCommerce file directly.

      Reply
  • Is it possible to change just one instance of a label? For example, my site has several forums using BuddyPress and I will like to change the label of one of the forums from “New Discussion” to “New Request”. Note: only one instance of the label is to be changed all other instances remain as the default

    Reply
  • Can this be used to target specific divs? Like a div with a class of this
    Yada, yada in here

    Reply
    • It cannot target a specific DIV. It is meant to search out a string of text and replace the text with the new string.

      Reply
  • Can someone rewrite it with an else if please? I got no idea how to do it and what im writing its not working.

    Reply
    • We have a special process for a request like this that is not repair. It’s a simple process that initiates a form that you can fill out with the details of your project which are sent in to a group of developers to quote the work.

      Please visit the link below for more details.
      https://www.wpfixit.com/custom-wordpress-project/

      Reply

Leave a Reply

Your email address will not be published.