WordPress 3.0.1 を適当にインストール。
パーミッション変更など。
757 ./wp-content/uploads
646 ./.htaccess
646 ./sitemap.xml
プラグインはとりあえず下記4つを組み込み。
Google XML Sitemaps
Ultimate Google Analytics
Ktai Style
Exec-PHP
Google XML Sitemaps 3.2.4
「sitemap.xml」のパーミッションにa+w付与くらい。
Ultimate Google Analytics 1.6.0
google analytics のアカウント取得前提。
設定の「Account ID」に「UA-XXXXXXXX-X」を記述。
(管理ログイン中は計測されないのね…。)
Ktai Style 2.0.3
画像がリンク形式になる。
→フォルダ「./wp-content/uploads」にa+w付与で解決。(サムネイルが作れなかった)
amazonアソシエイトモバイル用タグを張りたい。
PCと携帯でタグを出し分けしたい。
→WordPressのフォーラムに解決策があったので「Exec-PHP」を追加でプラグイン!
これでひとまずアソシエイトタグを出し分け可能になった。
Exec-PHP 4.9
プラグイン自体は特に設定は行わないが、設定→投稿設定の「不正にネスト化した XHTML を自動的に修正する」にチェックを外さないとうまく動作しないらしい…。
調整
amazonアソシエイトモバイル用の画像を直接表示と、外部サイトへの直接リンク設定。
ファイル「./wp-content/plugins/ktai-style/themes/default/functions.php」新設↓
<?php function ks_keep_amazon_image($replace, $orig, $src) { if (preg_match('#^http://ecx.images-amazon.com/images/#', $src)) { $replace = $orig; } if (preg_match('#^http://www.assoc-amazon.jp/#', $src)) { $replace = $orig; } return $replace; } add_filter('ktai_image_to_link', 'ks_keep_amazon_image', 10,3); function ks_direct_external_link($link_html, $href, $label) { return '<a href="' . attribute_escape($href) . '">' . $label . '</a>'; } add_filter('ktai_external_link', 'ks_direct_external_link', 90, 3); ?>
記事内のタグコードの書き方は下記php制御文。
モバイル用は記述順序を変更している。
PC用のIFRAMEはそのまま記述。<?php if (is_ktai()) { ?> <a href="Aタグのリンク先">ALTの商品名をココに移動</a><br /> <img src="http://ecx.images-amazon.com/images/XXXX.jpg" style="vertical-align:middle;" /> <img src="http://www.assoc-amazon.jp/e/ir?t=XXXX...." width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><br /> <?php } else { ?> <iframe src="IFRAMEのリンク先" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe> <?php } ?>↓サンプルは直前の記事
クルマの中で携帯を充電する
タグ: wordpress