Automate Affiliate Linking in ALL your WordPress Posts


Why are people buying this $50 WordPress Plugin (worth $100) when you can accomplish something extremly simular for free with ONE line of code?

Don’t Waste Money On The Simple Things…
I happened upon DealDotCom last Wednesday Sept 19th (I’m a regular WOOTer as well) and saw they had a spiffy new product: WP Affiliate Pro. This WordPress application looks great and is very useful indeed. I need to give credit to the author for coming up with it in the first place. Its functionality allows you to insert affiliate links into your blog quickly and easily based on existing text found throughout your blog and track its success. It is professionally done and is functional. You defiantly get what you pay for. With a large enough site I’m sure you’ll see a return on your investment. John Chow bought this but that’s to be expected with a site that large. But he too could have gotten it for NOTHING.

If you’re not a very large site…
Here’s the kicker… Its on DealDotCom for $49.88 (which if that’s a deal I’m afraid to ask what it was before hand – UPDATE it was $97). This makes me sad. Why on earth would someone pay almost $50 for that software when you can quickly integrate something similar with ONE line of code.

Granted this single line of code does not offer tracking features, but with the quick creation of a table in mySQL and two or three more lines of code you can easily integrate tracking. Four more lines would give you a nice little reporting page. If I get enough comments (and time) I’ll write that out as well, but for now here’s something you can work with. This example will replace “google” (not case sensitive) with a link to their site in every post on your site. You can replace the link with your affiliate ID to make some income on the referrers or use it with your other affiliate products.

Locate: wp-includes/template-functions-post.php
Find: $content = get_the_content($more_link_text, $stripteaser, $more_file);
Insert this below: $content = str_replace(” google “, ” < a href="" mce_href="" >Google< /a> “, mb_strtolower($content, mb_detect_encoding($content)));

I’m sure you’re going to have more then one replace though so lets put this stuff in an nice array for multiple substitutions:

  1. $patterns[0] = '/ adsense /';
  2. $patterns[1] = '/ google /';
  3. $patterns[2] = '/ ppc /';
  4. $replacements[2] = " <a href=\"\">Adsense</a> ";
  5. $replacements[1] = " <a href=\"\">Google</a> ";
  6. $replacements[0] = " <a href=\"\">PPC</a> ";
  7. $content = preg_replace($patterns, $replacements, mb_strtolower($content, mb_detect_encoding($content)));
  1. Create more replacements by continuing the numeric progression in the array. If you combine some of the tactics from my post on Increasing Affiliate Income – Blindfolding Your Links you will also be able to blindfold those links with your own URL and add in tracking much easier.
  2. Make sure you have spaces between the outsides in case your word(s) show up in a hyperlink, otherwise it would replace that too. Delete the two spaces in the beginning of the anchor part (It shows up as a link on this post otherwise).
  3. Remember to escape any additional quotes with a backslash as seen in the example. I cant count how many hours I’ve wasted on forgotten semi-colons and backslashes.
  4. mb_detect_encoding() may work oddly with different encodings. Especially if your site is in a language other then English. In this case see further details on about what to specify it as.
  5. This shouldn’t effect your existing links but keep an eye out, I whipped this up in five minutes.

If its not already apparent, I’m cheep and that doesn’t exactly do much for me when it comes to marketing solutions for my projects. But you would be surprised what you can do when you don’t just throw money at the problem – and you learn so much more in the process. This strategy gives me some of the best ideas. More often then not, ideas within ideas are found because of the unique ways you come up with to tackle problems. Besides what would the fun in just paying your way to the top? Dorothy’s yellow brick rode is one of dollars for many these days. Its more fun to impose a “cash crutch” on yourself and find creative ways around the mainstream choices.

I started this blog 2 months ago and readers are steadily climbing faster then expected:

feedburner trend rob malon

I didn’t spend a penny on marketing or software (not that it wouldnt be smart to). Unless you include server costs, I never spend more then that. But I also run other projects off it so I already had it as a resource. My point is, if you learn enough, theres really nothing you cant do without a bit of time and effort. And sometimes less effort then you would think.

rss feed rob malon Interested in receiving instant updates on automating websites for passive income as well? Click Here to subscribe or use the email subscription box on the top right of this site.

Respond: Leave A Comment | Trackback URL

Entrupeners, Subscribe for the lastest tools, tips, and tutorials.

13 Responses to Automate Affiliate Linking in ALL your WordPress Posts

  1. Pingback:

  2. Rob congratulations on the traffic, its hard work. I was up to all hours last night working on my own. Thanks for the look see at it. I was ranked 8 million on Alexa in early August and I’m down to 3 mill range as of today. Thanks for all your help

  3. Pingback: Sweet Gain » Blog Archive » Link Storm

  4. I’ve been using something called sh-autolinkon all my blogs and it works really well -for free!

  5. Pingback: Automate Affiliate Linking Script - php and javascript scripts

  6. Thanks for the link Andy. I was told theres another similar solution floating around and cant find the link. This one looks a little more involved to the novice, but it gives people plenty of options. I wonder how many people would have bought that if they only knew…

  7. I know, I have been using the internet since it was called Fidonet and I’ve virtually never had to pay for any kind of software ever! There’s always a way to do it for free somewhere.
    some people are happy to pay for the convenience of not having to search for a free version or want some kind of assurance that they will get future support so there’ll always be people who pay for stuff that can be found for free which is good news for places like deal a day and others

  8. Great tip and even better that you dropped a link to the code download for those of use who type with the palms of our hands. I love finding simple coding solutions to avoid buying software but I spend more time on deleting my typing errors than actual coding.

    Thank you. And I look forward to the possibility of “the quick creation of a table in mySQL and two or three more lines of code you can easily integrate tracking. Four more lines would give you a nice little reporting page.” You rock.

  9. I think you’d like to try the free plugin i developed, used to find out which keyword the visitor has typed in the search engine he comes from and then show a message (affiliate link) based upon that.

  10. A plugin for wordpress? I made something like that for a slightly different purpose which I’ll explain in an article next month. I haven’t taken the time to create mine as a plugin specifically for wordpress. It’s easy enough to implement without having to interface it with wordpress.

    Applying search engine keywords to affiliate text links is a great idea though. I’m doing something like that using a different method (my own site search) which I’ll be explaining more about in a later article.

    Sorry if detail is lacking here…easier to explain it once ;) .

    By the way, the script that I created for search engine keyword logging/display covers google, yahoo, and msn. Though it wouldn’t be hard to add to that list. If there are any other popular ones people like to use let me know now and I’ll include when I release my method.

  11. Nice to hear that, I’m going to subscribe to your RSS feed since you’ve written many good posts ;-)

Leave a Reply

Custom Theme by Rob Malon | Content & Design © 2010 - RobMalon.Com - Chicago, Illinois