Change Text without a Plugin in WordPress

Struggling to change specific text on your WordPress site? Learn how to force text replacements with a simple snippet—no coding skills required! Perfect for stubborn theme or plugin text.

 •


WordPress is a powerful platform that gives users the flexibility to customize their websites in many ways. One of the most useful features is the ability to change default text that appears in different areas of your site, such as buttons, form placeholders, or plugin-generated content. This can help align your site’s messaging with your brand or audience.

In this post, we’ll show you how to easily change specific words or phrases on your WordPress site using a simple PHP script. This approach allows you to make quick adjustments without modifying your theme files or adding plugins.

Why Customize Default Text in WordPress

Default text in WordPress often feels generic and doesn’t reflect the unique personality of your website. By customizing it, you create a stronger connection with your audience and improve their experience. Whether it’s tailoring the “Read More” button, modifying login page greetings, or personalising WooCommerce product messages, these changes can make your site feel more professional and aligned with your brand.

Customised text also helps with clarity. For example, instead of generic placeholder text, you can guide users with specific instructions or provide tailored messages that build trust. From a business perspective, personalised text improves engagement, making users more likely to explore your site or take action, like purchasing a product.

In the UK, where online users value clear and trustworthy communication, small tweaks can set you apart. Updating default text is a simple yet powerful way to create a website that feels thoughtful, approachable, and distinctly yours.

Changing the default text in WordPress can help achieve several objectives:

LKeeping your website’s language consistent with your brand’s tone and voice.

Adapting your site’s text to fit regional language preferences or cultural nuances.

Making text more clear and easier to understand for your audience.

Adding a personal touch to your website to enhance its identity.

By using this approach, you can create a seamless experience for your visitors without complicating your WordPress setup.

The PHP Script to Change WordPress Text

To modify text across your WordPress site, you’ll need to use a simple PHP script. This script works by applying WordPress filters to change specific words or phrases before they are displayed on the site.

Here’s the PHP script that you can use:

/**
 * Function to change specific words in WordPress text translations.
 * By @sebdelaweb
 */
function wpfi_change_text( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'OLDTEXT1' :
            $translated_text = __( 'NEWTEXT1' );
            break;
        case 'OLDTEXT2' :
            $translated_text = __( 'NEWTEXT2' );
            break;
        // Add more cases as needed
    }
    return $translated_text;
}

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

With this script, you can replace any default text (like “Submit” or “Enter your name”) with your custom text.

/**
 * Function to change specific words in WordPress text translations.
 * By @sebdelaweb
 */
function wpfi_change_text( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'OLDTEXT1' :
            $translated_text = __( 'NEWTEXT1' );
            break;
        case 'OLDTEXT2' :
            $translated_text = __( 'NEWTEXT2' );
            break;
        // Add more cases as needed
    }
    return $translated_text;
}

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

How to Implement the Script

Now, let’s walk through the steps for adding the PHP script to your WordPress site:

Access Your Theme’s Functions File

  1. Go to your WordPress dashboard.
  2. Navigate to Appearance > Theme Editor.
  3. Open the functions.php file of your active theme.

Add the Script

  1. Copy and paste the PHP script above into your functions.php file.
  2. Replace 'OLDTEXT1' and 'NEWTEXT1' with the text you want to change and its new version. Repeat for any additional words or phrases.
  3. Click Update File to save your changes.

Example Use Cases

Here are some common examples where you might want to change text across your site:

Changing Button Text

For instance, if you want to change a button’s text from “Submit” to “Send,” simply add the following line in the script:

case 'Submit' :
    $translated_text = __( 'Send' );
    break;

Modifying a Form Placeholder

To update a form placeholder from “Enter your name” to “Your full name,” you can add:

case 'Enter your name' :
    $translated_text = __( 'Your full name' );
    break;

Adding More Cases

If you need to change more than just a couple of phrases, simply add more case statements to the script:

case 'OLDTEXT3' :
    $translated_text = __( 'NEWTEXT3' );
    break;

Repeat the process for any additional text you want to change.

Final Thought

Customizing your WordPress site’s text can greatly enhance user experience and help your site better reflect your brand. By using the simple PHP script we’ve provided, you can change specific words and phrases without needing to install plugins or modify core files. This method is not only easy to implement, but also ensures your customizations will be safe during theme updates.

For more tips and expert guidance on WordPress and web development, visit Seb de la Web. We provide valuable resources and solutions to help you get the most out of your WordPress website.

Continue learning

flatsome designs

200+ Free Designs

Get for free

Need a custom design? Hire Seb today

Get the #1 All In One Design Agency for Flatsome

Hire Seb & Tas