(Help) Change all my affiliate IDs with a script

andreint

BuSo Pro
Joined
Oct 20, 2014
Messages
167
Likes
241
Degree
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!
 
@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.
 
You'd better backup your MYSQL database before you do any of this.
 
Back