Remove all links to a specific website

So, my cousin owns a fashion blog and she recently had a fall out with a brand of shoes and she wants to remove all the links on all posts that point to the brand website.

So, is there a way I can automatically via SQL commands or maybe a plugin check all posts on the blog and turn links like this:

Read More
<p style="text-align: center;"><a href="http://specific-url.com/prod1">Awesome Product 1</a></p>

Into just text without links:

<p style="text-align: center;">Awesome Product 1</p>

The ideia is basically to find all links starting with http://specific-url.com/ and remove the <a>tag.

Thank you.

Related posts

2 comments

  1. You can use the Search Regex plugin. This will allow you to create a regular expression to intelligently search and replace across all of your posts.

    After you activate the plugin, go to Tools, Search Regex. If you want to remove all links to http://example.com, here is one regular expression you could try:

    /<a href="http://example.com[^>]*>([sS]*?)</a>/
    

    Enter that into the “Search pattern” box, and enter $1 into the “Replace pattern” box. Choose “Post content” for the Source, and check the “Regex” checkbox. Then click the “Replace” button. This won’t change anything in your database (yet), but it will show you a preview list of all the changes that it will make. To actually make the changes, click the “Replace & Save” button. Or if you see from the preview that your regular expression is matching something you don’t want it to, then change your regular expression and try again.

    With a bulk edit like this, it’s probably a good idea to back up your database before you begin, just in case you make a mistake.

    Screenshot:

    enter image description here

Comments are closed.