How to bulk edit a load of URL's in Wordpress?

Soldato
Joined
12 Jan 2003
Posts
20,263
Location
UK
Hi everyone, looking for some advice if possible.

I have a Wordpress site with a load of external links at the moment for a certain affiliate programme. They all begin with the same URL prefix (https://www.abcde.com/ for example) but the rest of each link is different as it links to the given product. I need to bulk edit all of these links across my Wordpress site if possible, to move to a different affiliate link partner. Unfortunately the new URL structure is different so i can't simply replace the prefix section and leave the rest as it is, i need to basically remove all those links.

What i'd like to be able to do is search for all links that begin with that prefix, regardless of the rest of the URL, and replace all of them with a single URL that is the same, but from the new affiliate system.

I have tried some plugins search as "better search and replace" but they all seem to lack the ability to find any URL starting with X, they will only find literally just the text you enter and replace that. but while each of these links starts the same, they are all different overall

any suggestions or advice?
 
Associate
Joined
3 Jun 2005
Posts
2,130
Location
The South
If you've got DB access then you could do a regex replace on the anchor tags within pages/posts (forgotten the table name WP uses for posts) using regex like (https://regex101.com/r/cM8K7z/1) -
Code:
/https:\/\/www\.abcde\.com\/.+(?=")/g

Can't say i've had or tried to do this and i don't doubt there is a "proper" Wordpress solution but as i'm not a massive fan of WP this would be the sledge hammer approach i would use :cry:
 
Associate
Joined
3 Jun 2005
Posts
2,130
Location
The South
Top Bottom