Easily modify theme strings

On many themes you will encounter some hard-coded strings, which you might want to alter.

Your options on altering them are:

  1. Locate the strings in the theme’s files and edit them, which is not advised.
  2. Create a child theme, load its text domain, copy over any necessary files and make your changes. This is a proper way to go about it, but it can get complicated.
  3. Use a plugin like Say What to help you do this quickly and easily. Read on for info on how to do this.

On this guide we will see how we can change the ‘from’ bit on the room pricing tag on our Santorini theme.

room_from

Start by installing and activating the Say What plugin.

Once done navigate to Tools > Text Changes. You will be greeted by this screen:

text_changes

Click the Add New button and you will see this:

text_changes_add_new

Let’s fill in the boxes.

In the Original string box we fill in the string we are interested in modifying, in our example we will add in the word from and move on.

In the Text domain box we need to fill in the theme’s text domain, here’s how to find it:

  1. On some themes you will find the text domain in the small descriptive block at the top of the style.css file, for example here is this bit from the Twenty Fifteen default WordPress theme: text_domain_stylesheet
  2. Some themes might not include this information in the stylesheet (as is the case with Santorini) and we will have to take a look at the functions.php file. We are looking for the load_theme_textdomain function. Here is the relevant line from Santorini (on most of our themes the function will be towards the top of the file) santorini_text_domain

As we can see above the text domain for Santorini is ci_theme (which is the case for many of our themes), we place this in the Text domain box and proceed.

In the Replacement string box we place the string we want to see instead of the original one, let’s go with starting at.

This is what our configured panel will look like:

text_changes_final

We then hit the Add button and we are done.

If we check the room listing page again this is what we see:

modified_string

Success!

No votes yet.
Please wait...

Get 30% Off! Coupon code: WORDPRESS - Join Today!