アクセスカウンターが付けたいと思い検索したところ「bsuite」なるものを発見し早速付けてみたのですが・・・エラーが出てうまく動かない・・・う~んいろいろ機能があって良さそうだったのですが、今日は色々いじくってがんばる気にはなれずさっさと諦めて、次に見つけた「counterize II」を設置してみました。
こちらは全く問題なく動作しました。
・・・設置方法は説明するほどではないですが、こちらからダウンロードして、解凍後いつもの「plugins」フォルダに転送して「有効化」すればOKです。
後は日本語化のためにフォルダの中の「counterize-ja_UTF.mo」と「counterize-ja_UTF.po」を「counterize-ja.mo」と「counterize-ja.po」にそれぞれリネーム
「管理画面」の「各種設定」で設定します・・・設定は日本語表示にすれば見れば判ると思います (^∀^2)、
「管理画面」の「管理」でログが見れます。
カスタマイズ
参考サイト
デフォルトだと今日のカウントしか表示できないので昨日のカウントも表示できるようにカスタマイズ「counterize.php」ファイルの 「# Returns amount of hits today.」のまとまりの下あたりに
# Returns amount of hits today.
function counterize_gethitstoday()
{
$today = date("Y-m-d");
$sql = "SELECT COUNT(1) FROM ".counterize_logTable()." WHERE timestamp >= '$today'";
$wpdb =& $GLOBALS['wpdb'];
return $wpdb->get_var($sql);
}
# Returns amount of hits yesterday.
function counterize_gethitsyesterday()
{
$today = date("Y-m-d");
$yesterday = date("Y-m-d",strtotime("-1 day"));
$sql = "SELECT COUNT(1) FROM ".counterize_logTable()." WHERE timestamp >= '$yesterday' AND timestamp < '$today' ";
$wpdb =& $GLOBALS['wpdb'];
return $wpdb->get_var($sql);
}
# Returns amount of hits during the last 7 days.
function counterize_gethitstoday()
{
$today = date("Y-m-d");
$sql = "SELECT COUNT(1) FROM ".counterize_logTable()." WHERE timestamp >= '$today'";
$wpdb =& $GLOBALS['wpdb'];
return $wpdb->get_var($sql);
}
# Returns amount of hits yesterday.
function counterize_gethitsyesterday()
{
$today = date("Y-m-d");
$yesterday = date("Y-m-d",strtotime("-1 day"));
$sql = "SELECT COUNT(1) FROM ".counterize_logTable()." WHERE timestamp >= '$yesterday' AND timestamp < '$today' ";
$wpdb =& $GLOBALS['wpdb'];
return $wpdb->get_var($sql);
}
# Returns amount of hits during the last 7 days.
そして、カウント数を表示させたいところに下記を記述
Today: <?php echo counterize_gethitstoday(); ?>
Yesterday: <?php echo counterize_gethitsyesterday(); ?>
Total: <?php echo counterize_getamount(); ?>
Yesterday: <?php echo counterize_gethitsyesterday(); ?>
Total: <?php echo counterize_getamount(); ?>
そして、どうせなら「管理画面」にも表示させたいと言うことで
「counterize.php」の1267行目あたりに
<div class="wrap">
<h2><?php _e('Hit Counter',"counterize");?></h2>
<table width="100%" cellpadding="3" cellspacing="3">
<tr>
<td scope="col" style="width: 10%" align="center"><?php _e("Total hits: ",'counterize'); ?>
</td>
<td scope="col" style="width: 15%" align="center"><?php _e("Hits from unique IPs: ",'counterize'); ?>
</td>
<td scope="col" style="width: 15%" align="center"><?php _e("昨日の訪問者(HIT数): ",'counterize'); ?>
</td>
<td scope="col" style="width: 15%" align="center"><?php _e("Total hits, today: ",'counterize'); ?>
</td>
<td scope="col" style="width: 15%" align="center"><?php _e("Hits from unique IPs, today: ",'counterize'); ?>
</td>
<td scope="col" style="width: 15%" align="center"><?php _e("Hits, the last 7 days: ",'counterize'); ?>
</td>
<td scope="col" style="width: 15%" align="center"><?php _e("Unique hits, the last 7 days: ",'counterize'); ?>
</td>
</tr>
<tr>
<td align="center"><strong><?php echo counterize_getamount(); ?></strong></td>
<td align="center"><strong><?php echo counterize_getuniqueamount(); ?></strong></td>
<td align="center"><strong><?php echo counterize_gethitsyesterday(); ?></strong></td>
<td align="center"><strong><?php echo counterize_gethitstoday(); ?></strong></td>
<td align="center"><strong><?php echo counterize_getuniquehitstoday(); ?></strong></td>
<td align="center"><strong><?php echo counterize_getlatest7days(); ?></strong></td>
<td align="center"><strong><?php echo counterize_getuniquelatest7days(); ?></strong></td>
</tr>
</table>
</div>
赤文字を置き換え<h2><?php _e('Hit Counter',"counterize");?></h2>
<table width="100%" cellpadding="3" cellspacing="3">
<tr>
<td scope="col" style="width: 10%" align="center"><?php _e("Total hits: ",'counterize'); ?>
</td>
<td scope="col" style="width: 15%" align="center"><?php _e("Hits from unique IPs: ",'counterize'); ?>
</td>
<td scope="col" style="width: 15%" align="center"><?php _e("昨日の訪問者(HIT数): ",'counterize'); ?>
</td>
<td scope="col" style="width: 15%" align="center"><?php _e("Total hits, today: ",'counterize'); ?>
</td>
<td scope="col" style="width: 15%" align="center"><?php _e("Hits from unique IPs, today: ",'counterize'); ?>
</td>
<td scope="col" style="width: 15%" align="center"><?php _e("Hits, the last 7 days: ",'counterize'); ?>
</td>
<td scope="col" style="width: 15%" align="center"><?php _e("Unique hits, the last 7 days: ",'counterize'); ?>
</td>
</tr>
<tr>
<td align="center"><strong><?php echo counterize_getamount(); ?></strong></td>
<td align="center"><strong><?php echo counterize_getuniqueamount(); ?></strong></td>
<td align="center"><strong><?php echo counterize_gethitsyesterday(); ?></strong></td>
<td align="center"><strong><?php echo counterize_gethitstoday(); ?></strong></td>
<td align="center"><strong><?php echo counterize_getuniquehitstoday(); ?></strong></td>
<td align="center"><strong><?php echo counterize_getlatest7days(); ?></strong></td>
<td align="center"><strong><?php echo counterize_getuniquelatest7days(); ?></strong></td>
</tr>
</table>
</div>
黄文字を追記
※日本語を含むので保存方法は対応したもので保存してください。(UTF-8 とか EUC とか・・・) ・・・わからなければ半角英語が安全 (;^_^A アセアセ
以上終了です。
関係のある記事
5 users の書き込みがあります
[…] 参考 「counterize II」 を設置してみた WP プラグイン | 頭脳外部メモリー 「独学で趣味を満喫」 http://le-coeur.net/archives/188 […]
[…] 「Counterise II」の日本語化や設置の方法は、【頭脳外部メモリー 「独学で趣味を満喫」】さんの「counterize II」 を設置してみたに詳細があるのでそちらを参照してもらうとして。 […]
[…] 説明サイト http://le-coeur.net/archives/188 […]
[…] 説明サイト http://le-coeur.net/archives/188 […]
[…] 説明サイト http://le-coeur.net/archives/188 […]
コメントほしぃ~よぉ~ σ(^◇^;)