Search and Replace Plugin (CMSR) - Use Case - How to Replace Content On the Fly


Use Case - How to Replace Content On the Fly

Back to User Guide

Note: This guide covers features from:

Video Use-Case


Introduction

The Search and Replace plugin allows you to easily replace text in all types of posts and pages, including theme and plugins generated content. 

It works via rules: you tell it  "x" should become "y". Then, every time a visitor visits a page with "x", he/she will see "y". 

Note that the content will only change to the visitor. The change will not be applied to your database.

Use Case Front-End

Replacing "nancy" to "REGINA" and using the Replacement widget:

Replacing one word with another one and using the replacement widget - WordPress Plugin Search and Replace
Replacing one word with another one and using the replacement widget

Case-sensitive rule:

Example of replacing case-sensitive words - WordPress Plugin Search Database and Replace
Example of replacing case-sensitive words

Use Case Assumptions

In this example use case guide, we'll cover how to create rules for replacing the content on the fly. 

We consider that you have already bought the plugin, but not installed it. 

It follows:

Installing the Plugin

The process is the same for all CM plugins.

CreativeMinds Customer Account Dashboard - Downloads tab
CreativeMinds Customer Account Dashboard
  • Download the plugin from your customer dashboard.
  • Log in to WordPress and navigate to the WordPress Admin  → Plugins settings.
  • Click on Add New.
  • Activate it and add the license.

Learn more: Getting Started - Plugin Overview


Creating Replacement Rules

By default, the plugin does not make permanent changes to your content. Once you create replacement rules, they will be applied to visitors only while they access the page.

To create a rule, navigate to Admin Dashboard → Search & Replace → Settings.

Navigation to the plugin settings - Find and Replace Plugin WordPress
Navigation to the plugin settings

Under the Replacement Rules tab you can find a dashboard for creating rules.

Dashboard for managing replacement rules - WordPress Plugin to Mass Replace Links
Dashboard for managing replacement rules

To create a rule, we need to use the form at the bottom of the page:

Form for creating a replacement rule - Mass Replace Text in WordPress
Form for creating a replacement rule

Base Configuration

Let's start with some simple rule. For instance, we have a post with a book about Nancy Drew. And we need to replace the name Nancy to another one - for example, REGINA. So, we put a word/phrase we need to replace into the text area From String. Then we put a word/phrase that will be instead of this to the text area To String.

Fields for setting up the replacement - Search and Replace Plugin
Fields for setting up the replacement

Then we need to choose a place where the search and replace will be committed. There are 3 options under the Location dropdown:

  • All - To commit this rule of searching and replacing everywhere on the site.
  • Include - To commit this rule only on the chosen posts/pages.
  • Exclude - To commit this rule on all posts/pages, except the chosen ones.

As now we need to commit this rule on one definite post, we choose the option Include and add needed post to the list. You can add any number of posts and pages to these lists.

Choosing where to apply the replacement rule - WordPress Plugin Search and Replace
Choosing where to apply the replacement rule

Then click the button Add New Rule.

Result

Our first rule is created! Now let's see the result on the Front-end:

Front-end example of the replacement using the widget - WordPress Plugin Search Database and Replace
Front-end example of the replacement using the widget

Note: In this front-end example we used the widget to enable and disable replacements - we will talk about it more detailed lower.

As you could see, in this example the rule wasn't case-sensitive - we used the word "nancy" for replacing, and all "Nancy" words were replaced. Now let's create a case-sensitive rule. We do all the same, but also turn on the option Case, as shown on the screenshot below.

Result

Now let's see the result on the Front-end:

Replacing case-sensitive content - Find and Replace Plugin WordPress
Replacing case-sensitive content

As you can see, the words with exact match were replaced.

Managing Replacement Rules

There are a few actions you can do to manage your rules:

  1. Pause - You can stop committing any rule at any moment by just checking the box Pause and clicking Update. Uncheck the box to make this rule work again.
  2. Update - Click this button to save changes every time you edit the rule.
  3. UpdateDb - The main functionality of the plugin is making replacements on the fly, without changing them to the database. However, it's possible to commit replacement rules to the database by clicking this button. Learn more about it in this guide: Search and Replace Plugin (CMSR) - Saving Changes to the Database
  4. Delete - Click this button to remove the rule.
  5. Save All Changes - If you edited a few rules, you can update them all at once by clicking this button.
Managing replacement rules - WordPress Plugin to Mass Replace Links
Managing replacement rules

Restrictions

There are additional options you can set for each rule - these are Timeframes and Exclusions.

Addiotional restriction options - Mass Replace Text in WordPress
Addiotional restriction options

Timeframe

Setting a timeframe means that this rule will be applied only within the range of dates and time defined in the restriction. You can add more than one timeframe.

To add timeframe click on the button Add Timeframe.

A new box will appear for setting From and To dates and time for the restriction. 

Adding timeframe - Search and Replace Plugin
Adding timeframe

Important: when you set the date and time for the restriction, you need to know that this option works according to the Universal time - and it can be different from the local time that you set in your site settings. To check it, navigate to Admin Dashboard â†’ Settings â†’ General and scroll to the option Timezone.

Site timezone setting - WordPress Plugin Search and Replace
Site timezone setting

There are displayed Universal time and Local time.

For example, the case that you see on the screen we have a difference in 3 hours between universal and local time set on the site. So, if we want the replacement rule work from 12 to 13 o'clock according to the local time, we need to set the time in the Add Timeframe option from 9 to 10 o'clock.

Exclusions

Adding exclusions means that this rule will not be applied to the chosen items like:

  • Site Title
  • Page Title
  • Content
  • Excerpt
  • Comments

To add exclusion click on the button Add Exclusion.

A new box will appear with a set of checkboxes.

Each of the checkboxes allows excluding given rule from working in associated area. For example, checking Page Title means that this rule will not work in titles, even if it's defined differently in the General Settings.

Additional locations for applying the replacement rules - WordPress Plugin Search Database and Replace
Additional locations for applying the replacement rules

Settings

Under the Settings tab you can define some general settings for all rules.

General plugin settings - Find and Replace Plugin WordPress
General plugin settings
  • Search & Replace edit page display - Choose if to display items on a single page or paginate them.
    • Search & Replace items per page - Define amount of items per page. Works only if you've chosen to paginate items in the previous option.
  • Search & Replace on post types - Enable search and replace for posts, pages or any other custom post types.
  • Search & Replace excluded posts/pages - Set here posts and pages that you want to exclude from search and replace parsing.

    Note: options Search & Replace on post types and Search & Replace excluded posts/pages have higher priority than the options that you define in rules. For instance, if in the rule you include some post to the rule for parsing, but this post is excluded in the Search & Replace excluded posts/pages option, then the rule will not be committed for that post.

Last 5 options have lower priority than corresponding options in creating rules. So, they can be redefined for each rule:

  • Search & Replace in the site title
  • Search & Replace in the page/post title
  • Search & Replace in content
  • Search & Replace in excerpt
  • Search & Replace in comments

Replacement Widget

The Search and Replace plugin has a Replacement Widget that allows to control on the Front-end if to enable or disable replacement. You could see how it works in the example above. 

To configure the widget head to the Replacement Widget tab.

Replacement widget settings - WordPress Plugin to Mass Replace Links
Replacement widget settings

The options are:

  • Display Widget for - Select who can see the Widget:
    • Show to anyone - In this case the widget will be shown to all users, including non-logged-in.
    • Show to logged users - The widget will be shown only to logged-in users.
    • Show to admin only - The widget will be shown only to admin.
      • Admin can save changes to database - This option is available only if you've chosen Show to admin only in the previous option. In this case, the admin can commit permanent changes to the database for the post, where he uses this option.
  • Tooltip ON/OFF Widget Label - Here you can customize or translate the Widgets Label.
  • Tooltip ON/OFF Widget disable text - Customize the text of the link disabling the Search & Replace functionality.
  • Tooltip ON/OFF Widget enable text - Customize the text of the link enabling the Search & Replace functionality.
  • Add to the top/bottom of each post - Note that it will only be added to the post types selected in the general setting.

How it looks like on the Front-end:

  1. Tooltip ON/OFF Widget Label.
  2. Tooltip ON/OFF Widget disable/enable text.
  3. Admin can save changes to database (this button can be displayed only for admins).
Replacement widget on the front-end - Mass Replace Text in WordPress
Replacement widget on the front-end

End Result

Following instructions found in the plugin and guides, you should be able to configure replacing content on the fly.

Use Case Front-End

Replacing "nancy" to "REGINA" and using the Replacement widget:

Replacing one word with another one and using the replacement widget - Search and Replace Plugin
Replacing one word with another one and using the replacement widget

Case-sensitive rule:

Example of replacing case-sensitive words - WordPress Plugin Search and Replace
Example of replacing case-sensitive words

Extra - Export/Import

The Search and Replace plugin allows you to export and import all replacement rules, including paused ones. This is done via a .json file.

This is useful for transferring rules from different sites or add/remove them in batch.

Navigate to Admin Dashboard → Search & Replace → Export/Import.

Navigation to the export and import settings - WordPress Plugin Search Database and Replace
Navigation to the export and import settings

There you can see two sections - Export and Import.

Export and import settings - Find and Replace Plugin WordPress
Export and import settings

Export

There are two ways of exporting:

  • Export all your replacement rules (even paused) and plugin settings.
  • Export only replacement rules, without plugin settings. To do this you need to check the box Export replacement rules only (.CSV format).

To export the file, click the button Download Export File.

Import

To import replacement rules (and plugin settings if you've exported them), click the button Choose File to upload the file. Then click the button Upload file and import.


More information about the Search and Replace Plugin for WordPress

Other WordPress products can be found at CreativeMinds WordPress Store

Let us know how we can Improve this Product Documentation Page

To open a Support Ticket visit our support center
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.