(Help) Change all my affiliate IDs with a script

Joined
Oct 20, 2014
Messages
117
Likes
118
Degree
1
#1
Hey guys,

I just created a new Associates account and need to change my ID on 100+ posts. I'd like to skip the manual labor and complete the task with a couple of lines of code (which I don't know how to write xD ).

I may be wrong, but I think that @Ryuzaki said something a while ago about using javascript/jQuery to change all your affiliate links with one line of code.

Anyone here willing to help me out?

All my links are unmasked/not cloaked.

Thanks!
 

Ryuzaki

女性以上のお金
Staff member
BuSo Pro
Digital Strategist
Joined
Sep 3, 2014
Messages
3,163
Likes
5,777
Degree
7
#3
@andreint, the solution I use is a set of PHP redirects based on masking the link, so I can place the masked version in the posts like .com/out/product-name/ and then change the destination link in a text file, and it automatically "hot swaps" the links out across all posts. It doesn't really swap anything, just changes the redirection location.

In your case, you need to search for the instances of your original ID to replace them with your new ID, and all of that is located in the MySQL database.

This plugin creates an interface that will do this for you: https://wordpress.org/plugins/better-search-replace/

I've used this specific plugin countless times with no problems. A great feature is the "dry run" where you can see how many rows in how many tables need to be changed. It'll likely only be the wp_posts table, but you can search them all quickly.
 

CCarter

If they cease to believe in u, do u even exist?
Staff member
BuSo Pro
Boot Camp
Digital Strategist
Joined
Sep 15, 2014
Messages
2,060
Likes
4,622
Degree
5
#4
You'd better backup your MYSQL database before you do any of this.