Instructions: Exchange URLs and domains using search and replace in TablePress table cells

Search and replace - a particular challenge in TablePress tables, but one that can be solved.

As some readers already know, I implement a relatively large number of customer domains with the WordPress CMS system. And whenever a table is to be built into a post, there is only one plug-in that is the best choice for this task: TablePress by Tobias Bäthge. At this point, a big thank you for making the plugin available to everyone for free. The plugin is not only very easy to use and has an appealing look in the admin and in the output of the tables, but Tobias also offers excellent support. Usually you have an answer to your question within a few hours.

Search and replace - a particular challenge in TablePress tables, but one that can be solved.

Search and replace - a particular challenge in TablePress tables, but one that can be solved.

Find and replace in WordPress

And here we come to the next ingenious plugin: "Search and replace" from Inspyside GmbH. While other English-language plugins (such as "Better Search and Replace") have failures more often when it comes to large databases, this plugin works diligently through all the tables that belong to WordPress and replaces one string with another. The plugin even has an extra feature to change the WordPress domain if you move from one domain to another, but this feature doesn't solve the problem I had when changing URLs in TablePress.

The "Find and Replace" plugin is my current favorite in this plugin category. It still works where other plugins no longer work.

The "Find and Replace" plugin is my current favorite in this plugin category. It still works where other plugins no longer work.

The problem: URLs are not found and replaced

In the current case, I had a customer who had created a number of tables in TablePress, in which, in turn, very often images and links with URLs were incorporated. Unfortunately the "Find and Replace" plugin did not find some URLs, but they were definitely in the tables. After consulting the TablePress programmer, the problem was localized: The URLs are saved in JSON format and thus commented out with backslashes. This means that instead of "https://www.sir-apfelot.de", "https: \ / \ / www.sir-apfelot.de" is saved in the database.

This change makes it understandable why the plugin cannot find the URL in some cases. So that the plugin is also successful in TablePress, you have to search for and replace this spelling.

After that, however, I still had some URLs that were still not found. To see where the problem was, I looked directly in the database and found an additional notation there: double commenting out of the slashes. So instead of "https://www.sir-apfelot.de" there was "http: \\ / \\ / www.sir-apfelot.de".

Instructions: How to search and find!

In order to find all URLs or domains, you have to do a total of three runs with the plugin and search for and replace these three spellings:

  • https://www.sir-apfelot.de
  • https: \ / \ / www.sir-apfelot.de
  • http: \\ / \\ / www.sir-apfelot.de

Security query of the plugin prevents the replacement

The plugin still offers a small obstacle: If you want to replace the URL of the blog by running the plugin, it recognizes this and does not carry out the process in the current database but only offers a copy of the database with the desired changes as a download .

The additional security is ok, but I know what I'm doing and don't like this constraint. To switch off the security query, you can make a small change in the source code of the plugin:

In the file /inc/Page/SearchReplace.php you will find the following entry in line 245:

$ contains_site_url = strpos ($ search, $ this-> get_stripped_site_url ());

This is replaced by:

$ contains_site_url = strpos ($ search, "123". $ this-> get_stripped_site_url ());

 

Already works

-
Do you like my blog? Then I would be happy to receive a short review on Google. Easy leave something here for a moment - that would be great, thank you!

 

Effectively for free: iPhone 13 Mini and iPhone 13 deals with top conditions at Otelo - Advertisement

1 comment

  1. Shell says:

    World class tip! Big Merci!

Leave a Comment

Your e-mail address will not be published. Required fields are marked with * .