# 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);}
<h2>カウンタ</h2><ul><li>今日: <?php echo counterize_gethitstoday();?></li><li>昨日: <?php echo counterize_gethitsyesterday();?></li><li>合計: <?php echo counterize_getamount(); ?></li></ul>