Amazonアソシエイト・楽天アフィリエイトリンクがコピペ3秒で作れる
もしもアフィリエイト経由のAmazonリンク、楽天アフィリエイトリンクをコピペ1発で作るWordPress用ショートコードを作りました。
完成例
メリット・特徴
・カエレバと類似の機能
・ボタンのみ出力するので画像を好きなものを使用できる
・広告リンクがないのでユーザーが離脱するのを防げます。
・広告リンクがないのでドメインパワーを外に出さない。
機能一覧
Amazonリンク テキスト版
Amazonボタン
楽天リンクテキスト版
楽天ボタン
Amazonリンク テキスト版
文中に商品名や書籍名をアンカーテキストにしてAmazon検索結果画面へのリンクを作ります。
▼ 例えばこんな感じ
▼こんなに大量でもあっという間
エビスビールに合うおつまみ
記事内にある商品名や書籍名を以下のショートコードで囲むだけでAmazonリンクが作れます。
[MoshimoURLAmazonText "テキスト"]
Amazonリンク ボタン版
Amazonボタンを表示するショートコードです。
▼使用例
ショートコード
[MoshimoURLAmazon "テキスト"]
楽天アフィリエイト テキスト版
文中のテキストをクリックすると楽天検索画面に飛ばすショートコードです。楽天はクッキーにより30日間アフィリエイト期限があります。
ショートコード
[MoshimoURLRakutenText "テキスト"]
楽天アフィリエイトリンク ボタン版
楽天ボタンを表示させるショートコードです。Amazonボタンショートコードの後にスペースを空けて貼り付けてください。
ショートコード
[MoshimoURLRakuten "テキスト"]
ショートコードを使うための準備
以下のCSSとPHP関数をお使いのWordPressに貼り付けます。一度貼り付けるだけでショートコードはずっと有効です。テーマを変更したときは再度貼り付けてください。
CSS
以下のコードを、お使いのテーマのstyle.cssに追加してください。
(WordPress管理画面 ー 外観 ー テーマの編集 ー style.css)
/************************************ ** アフィリボタン(Amazon) ************************************/ .amazonaff { background: #232f3e; display: inline-block; padding: 0.3em 1em; text-decoration: none; color: white; border: solid 2px #232f3e; border-radius: 3px; transition: .4s; margin-top: 12px; margin-right: 2px; } /************************************ ** アフィリボタン(楽天) ************************************/ .rakutenaff { display: inline-block; padding: 0.3em 1em; text-decoration: none; background: #be0000; color: white; border: solid 2px #be0000; border-radius: 3px; transition: .4s; margin-top:5px; }
ソースコード(function.php)
以下のコードを、お使いの(子)テーマのfunction.phpに追加してください。
(WordPress管理画面 ー 外観 ー テーマの編集 ー function.php)
//もしもアフィリエイト経由のAmazonアフィリエイトURLを取得する(アンカーテキスト) function funcMoshimoURLAmazonText($title){ $strutf = urlencode($title[0]); $strutf2 = "https://www.amazon.co.jp/exec/obidos/external-search?keyword=".$strutf."&ie=UTF8"; $strutf2 = urlencode($strutf2); $link= "https://af.moshimo.com/af/c/click?a_id=556077&p_id=170&pc_id=185&pl_id=4062&url="; $link= $link. $strutf2; $output ="<a href=\"".$link. "\" target=\"_blank\">".$title[0]."</a>"; return $output; } add_shortcode('MoshimoURLAmazonText', 'funcMoshimoURLAmazonText'); //もしもアフィリエイト経由のアマゾンアソシエイトURLを取得する function funcMoshimoURLAmazon($title){ $strutf = urlencode($title[0]); $strutf2 = "http://www.amazon.co.jp/exec/obidos/external-search?keyword=".$strutf."&ie=UTF8"; $strutf2 = urlencode($strutf2); $link= "https://af.moshimo.com/af/c/click?a_id=556077&p_id=170&pc_id=185&pl_id=4062&url="; $link= $link. $strutf2; $output = "<a href='".$link."' target='_blank' rel='nofollow' class='amazonaff'>Amazonで探す</a>"; return $output; } add_shortcode('MoshimoURLAmazon', 'funcMoshimoURLAmazon'); //もしもアフィリエイト経由の楽天アフィリエイトURLを取得する(テキスト) function funcMoshimoURLRakutenText($title){ $strutf = urlencode($title[0]); $strutf2 = "https://search.rakuten.co.jp/search/mall/".$strutf; $strutf2 = urlencode($strutf2); $link= "https://af.moshimo.com/af/c/click?a_id=556078&p_id=54&pc_id=54&pl_id=616&url="; $link= $link. $strutf2 . "/-/"; $output ="<a href=\"".$link. "\" target=\"_blank\">".$title[0]."</a>"; return $output; } add_shortcode('MoshimoURLRakutenText', 'funcMoshimoURLRakutenText'); //もしもアフィリエイト経由の楽天アフィリエイトURLを取得する function funcMoshimoURLRakuten($title){ $strutf = urlencode($title[0]); $strutf2 = "https://search.rakuten.co.jp/search/mall/".$strutf; $strutf2 = urlencode($strutf2); $link= "https://af.moshimo.com/af/c/click?a_id=556078&p_id=54&pc_id=54&pl_id=616&url="; $link= $link. $strutf2 . "/-/"; $output = "<a href='".$link."' class='rakutenaff' target='_blank' rel='nofollow'>楽天市場で探す</a>"; return $output; } add_shortcode('MoshimoURLRakuten', 'funcMoshimoURLRakuten');
上記コードのa_id は、ご自身のもしもアフィリエイト用コードに変更ください。Amazon用と楽天用の2種類あります。
<調べ方>
http://shop.af.moshimo.com/af/shop/service/easyLink
にアクセス。
Amazonリンクの //af.moshimo.com/af/c/click?a_id=556077
ここの数値をコピーしてa_idを差し替えてください。
最後に
Amazonアソシエイト、楽天アフィリエイトのリンクは嫌味なくアンカーテキストとして設置できたりするので積極的にアフィリエイトリンクにする癖を付けておけば、少しずつ報酬が上がっていきます。
是非アフィリエイトリンクを増やす ということを意識してください。
また、このもしもリンクの使い方が分からない場合はコメントください。またバグがありましたらTwitter等でご報告いただきますと幸いです。
アフィリエイト初心者の方にぜひ活用いただきたいと思っていますので、アフィリエイト初心者の方にぜひこのURLをお知らせください。
コメント