勉強したことのメモ

Webエンジニア / プログラマが勉強したことのメモ。

WordPressで逆アクセスランキングの設置

  WordPress

WordPressに逆アクセスランキングを設置したかった。

ただ、広告が出ないタイプが必要。

プラグインか何かで済ませられないかと探すとドンピシャのがあった。
Sim Access
http://log.noiretaya.com/script/simaccess
「Download simaccess_1.1.1.zip」をダウンロードして解凍後、適当なディレクトリにアップする。

パーミッションを下記の通り変更。

simaccess
├ admin
├ class
├ log ( 707 or 777 )
├ .htaccess
├ access.php
├ access.sqlite ( 606 or 666 )
├ index.php
└ rank.html ( 606 or 666)

 

ほんでそのディレクトリのURLを叩くとログイン画面が出るので、

ID:admin
PASS:pass

でログイン。

 


 

で、フッターかフッターに解析用のJSタグを埋めておく。

<script type="text/javascript"><!--
document.write("<script type=\"text/javascript\" src=\"./simaccess/access.php?referrer=" + document.referrer + "\"></script>"); //src部分は適宜書き換え
// --></script>

 
アクセスランキングの表示はファイルに直接、

<?php include("rank.htmlへのパス"); ?>

 

と指定してもいいし、

Executable PHP widgetというプラグインを入れて、ウィジェットで呼び出してもいい。
尚、デフォのランキング表示はけっこう質素なので、

ol{
counter-reset:number;/* 名前を付けたカウンターをリセット */
list-style:none;/* olが数字を付けることをキャンセル */
margin:0;
padding:0;
}
ol li{
/* リスト部分は好きに装飾! */
}
ol li:before{
/* カウンタ(数字になる部分) */
counter-increment: number;/* 任意の名前を付けて! */
content: counter(number);/* 名前を付けたカウンターを呼び出し */
/* 色を変えたり、背景画像を敷いたり!自由自在! */
}

 

とか、

ol {
counter-reset:li; /* Initiate a counter */
padding:0; /* Remove the default left padding */
list-style:none; /* Disable the normal item numbering */
}
ol li {
position:relative; /* Create a positioning context */
margin:0 0 6px 2em; /* Give each list item a left margin to make room for the numbers */
padding:4px 8px;
border-top:2px solid #666;
background:#f6f6f6;
}
ol li:before {
content:counter(li); /* Use the counter as content */
counter-increment:li; /* Increment the counter by 1 */
/* Position and style the number */
position:absolute;
top:-2px;
left:-2em;
width:2em;
padding:4px 0;
border-top:2px solid #666;
color:#fff;
background:#666;
font-weight:bold;
font-family:"Helvetica Neue", Arial, sans-serif;
text-align:center;
}

 

とかで装飾するとよろしいかと。

olタグとかよくわかんない、tableタグが良いとかHTMLタグを変更したい場合は「class.access.php」を書き換える。

 - WordPress

  関連記事

WordPressで複数あるクリック広告をランダムで表示させる方法

同じクリック広告をずっと貼っているとクリック単価が下がると聞いた。WordPre ...

WordPressでスケジュール実行される日時を調べる方法

WordPressであるシステムを実装し、その際に毎日1回スケジュール実行(WP ...

WordPress4.0の新機能

WordPress4.0への更新が出来るとダッシュボードに書いてた。 互換性で変 ...

WordPressでタグやカテゴリの複数検索

WordPressでカテゴリのアンド検索や、タグとカテゴリの同時検索を行いたかっ ...

WordPress Popular Postsのサムネイルが表示されない

WordPressの人気記事を表示させるWordPress Popular Po ...