WordPress でユーザログインの有無に応じて表示を切り替える
なかのひとの解析に、自分が含まれるとイヤなので、ログインしているときは表示しないように書き換えました。
<?php global $current_user; if (!($current_user->ID)) { ?> <!-- nakanohito --> <script LANGUAGE="Javascript"> <!-- var refer = document.referrer; document.write("<a href='http://nakanohito.jp/'>"); document.write("<img src='https://nakanohito.jp/an/?u=******&h=******&w=128&refer="+escape(parent.document.referrer)+"&url="+escape(parent.document.URL)+"' border='0' width='128' height='128' />"); document.write("</a>"); //--> </script> <noscript> <img src="http://nakanohito.jp/an/?u=******&h=******&w=128" width="128" height="128" alt="Map" border="0" /> </noscript> <!-- nakanohito end --> <?php } ?>
$current_user->ID
が存在しないときは、なかのひとの画像を表示してやる感じ。複数のユーザで使うときはまた工夫が要りそうですが、とりあえず自分だけしかユーザがいないので、困らないからいいやという手抜きコードです。
ディスカッション
コメント一覧
まだ、コメントがありません