Add Amazon Affiliate Tags to WordPress Posts and Comments Automatically

Amazon Affiliate Tag is a handy little plug-in that will automatically – and retroactively – add the Amazon Tracking ID (which you need in order to cash in on the big Amazon affiliate bucks) to links to Amazon items in your site content.

Once you’ve installed the plug-in and added your Tracking ID on the simple settings page, you shouldn’t have to think about it again, and will be able to link freely to Amazon items without having to get pre-modified links from Amazon or adding the Tracking ID manually. In order to extend the functionality to your comments as well, you can add the following code to your theme functions.php file:

 *Add Affiliate Tags to Amazon Links in Comments
 *(for Amazon Affiliate Tags Plug-In)
if ( function_exists( 'AddTag' ) ) {

     add_filter( 'comment_text' , 'AddTag' );


For beginners: We wrap the filter in the `function_exists()` conditional so that you don’t absent-mindedly disrupt functionality (potentially crash your site in some contexts) the day you for some reason decide to deactivate or remove the plug-in. The `add_filter()` statement calls the `AddTag` function from the Amazon Affiliate Tag plug-in whenever the filter `comment_text` is called – which happens every time a comment is posted to a comment thread.

Seems like a natural to me, and I’ve recommended it to plug-in developer “MaximeB” (Maxime Bridon). Check the changelog on future Amazon Affiliate Tag updates to see if the functionality has been added, with or without further options to disable.

Commenter Ignore Button by CK's Plug-Ins

Leave a Reply

Your email address will not be published. Required fields are marked *