Need to change any WordPress text on your site? Get ready for an amazing snippet of code that will allow you to Change any WordPress Text on your entire site. This is WordPress Ninja stuff here and oh so useful!!!

Is there an output of text perhaps in a plugin that you want to change but you do not want to mess with the actual plugin code? Even if you did want to adjust the files inside a plugin to change the text this would be overwritten when there are future updates to the plugin.

Let us give you a real world use for this. A massive part of our site is ticket credit that customers purchase to redeem at a later date for WordPress Support. The plugin we use to distribute this ticket credit is WooCommmerce Smart Coupons.

Now the way this plugin is built is that it outputs the text Store Credit and Coupons through the areas it displays info. We wanted to change this output to Ticket Credit. So instead of editing over 13 PHP plugin files and over 1000 instances of these words, we simply used the snippet shared below to do this.

The best part is we can update the plugin as new versions are released and we never have to worry about our custom text changing. Change any WordPress Text can have many uses.


Change any WordPress Text With The Info Below

Below is the snippet you need to add to the functions.php file of your active theme.

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