Wordpress用カウンター plugin counterize II
Wordpress用のカウンターにcounterizeを使っていたが、counterize IIというのがあった。
以下からダウンロード
http://www.navision-blog.de/counterize-ii-english/#comment-14048
設定はこっちの方が楽だ。
pluginにアップロードして、activateするだけで、DBのテーブルも作ってくれる。
が、自分のところではエラーが出た。
以下のSQLを実行すればOKだった。
http://www.navision-blog.de/download/sqlscript_020401.txt
昨日のカウント数を表示できないのが、不満だーーーー!
ということで、counterize.phpに以下の関数を入れれば、表示できるようになるよ。
counterize.phpの function counterize_gethitstoday() 関数の下あたりに以下を追加
# 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);
}
テーマ側で
Today: < ?php echo counterize_gethitstoday();?>
Yesterday: < ?php echo counterize_gethitsyesterday();?>
このエントリーをソーシャルブックマークする →
2007-11-16 金曜日 at 3:08 pm
Counterize II があった…
Counterize というプラグインを入れたものの、どうやらかなり古いらしい。
という愚にもつかない記事(→アクセスカウンタ代わりのプラグイン)を書いて数分後。
Co (more…)
2008-5-9 金曜日 at 5:44 pm
[...] 参考サイト デフォルトだと今日のカウントしか表示できないので昨日のカウントも表示できるようにカスタマイズ 「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. 黄色部分を追記 そして、カウント数を表示させたいところに下記を記述 Today: <?php echo counterize_gethitstoday(); ?> 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> 赤文字を置き換え 黄文字を追記 ※日本語を含むので保存方法は対応したもので保存してください。(UTF-8 とか EUC とか・・・) ・・・わからなければ半角英語が安全 (;^_^A アセアセ 以上終了です。 ( 参考になったら、評価してねぇ~(o*。_。)oペコッ Previous Top [...]
2008-5-17 土曜日 at 6:52 pm
[...] ○芸人社長のブログ ≫ Wordpress用カウンター plugin counterize II [...]
2008-8-31 日曜日 at 5:38 am
[...] ブル設定が出来ずにエラー発生。調べたら、解決方法が芸人社長のブログのWordpress用カウンター plugin counterize IIにて丁寧に書かれていました。SQL文を実行して、あらかじめテーブルを作 [...]
2009-8-29 土曜日 at 11:18 pm
[...] こちらをご参考にしてください。 [...]
2009-9-23 水曜日 at 5:07 am
[...] を追加し、昨日のカウント数が表示出来るようにします。 参考:芸人社長のブログ [...]
2009-11-5 木曜日 at 8:13 am
[...] Wordpress用カウンター plugin counterize II | 芸人社長のブログ [...]
2010-1-4 月曜日 at 4:17 pm
[...] 参考サイト様 Cerisaie : >> Counterize IIの使い方memo Wordpress用カウンター plugin counterize II | 芸人社長のブログ [...]
2010-3-19 金曜日 at 8:13 am
[...] 基本下記のサイトなどを参考にしました。 芸人社長のブログ [...]
2010-5-1 土曜日 at 6:33 pm
[...] ・ 【おぼえがき】 ・ 【我が心のあれこれ】 ・ 【芸人社長のブログ】 有難うございました。 No [...]
2010-8-3 火曜日 at 4:57 pm
テーマファイルの編集とかがよくわからなくて諦めてたんですけど、テーマファイルの編集が必要ないプラグインがあったので使ってみました。
http://strong-seo.net/category/counterizeii-extension