Design > Theme Editor and click on Single Post (single.php). #Find this line: //date #Right after it, insert this line:
ID, 'Visited', 'times', 'so far today', '0', 'show'); } ?> #The line will display something like "Visited 300 times, 25 so far today" while viewing an individual post. #You may edit the wording to suit your preference. #If you wish to leave a word/phrase empty, use two quotes '' instead of just leaving it completely blank. #Insert only one instance of this line to avoid double tracking. #Change '0' to '1' if you wish to track unique sessions. #Change 'show' to 'noshow' if you donot wish to display the post count information. 2. To display the number of views per post on the main index page, click on Main Index Template (index.php) in the Theme Editor panel. #Find this line: #Right after it, insert this line:
ID, 'Viewed', 'times', 'so far today'); } ?> #The line will display something like "Visited 300 times, 25 so far today" under each post heading #while browsing your main page. #You may edit the wording to suit your preference. #If you wish to leave a word/phrase empty, use two quotes '' instead of just leaving it completely blank. 3. To add the sidebar widget, you may add it directly in the widgets panel of your theme (Design > Widgets). If your theme is not widget-ready, click on sidebar.php in the Theme Editor panel and do the following: #Add the following code:

Top Posts for Today

#You may edit the word "views" to your liking (e.g. visits, pageviews or leave it empty ''). #The list format defaults to an unordered list (ul). If you would like an ordered list, change it to 'ol'. 4. To add the sidebar widget to show your most popular posts overall, you may add it directly in the widgets panel of your theme (Design > Widgets). If your theme is not widget-ready, click on sidebar.php in the Theme Editor panel and do the following: #Add the following code:

Overall Top Posts

#You may edit the word "views" to your liking (e.g. visits, pageviews or leave it empty ''). #The list format defaults to an unordered list (ul). If you would like an ordered list, change it to 'ol'. CREDITS ------- 1. Thanks to Abe (www.yugatech.com/blog) for the whole idea of this plugin. */ #SET TIMEZONE OFFSET (UTC/GMT). To know your timezone, visit http://www.timeanddate.com/worldclock/ and click on the appropriate city. If you live in the Philippines, the offset is +8. $OFFSET = 0; #If you wish not to offset the date in which post views are recorded, leave it as is (0). add_action('init', 'jal_install'); $table_name = $wpdb->prefix . "dailytopten"; $table_name_all = $wpdb->prefix . "dailytoptenall"; $table_posts = $wpdb->prefix . "posts"; function jal_install () { global $wpdb; global $table_name; global $table_name_all; if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, time date DEFAULT '0000-00-00' NOT NULL, postnum int NOT NULL, postcount int DEFAULT '0' NOT NULL, UNIQUE KEY id (id) ) ;"; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); dbDelta($sql); } if($wpdb->get_var("SHOW TABLES LIKE '$table_name_all'") != $table_name_all) { $sqall = "CREATE TABLE " . $table_name_all . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, postnum int NOT NULL, postcount int DEFAULT '0' NOT NULL, UNIQUE KEY id (id) ) ;"; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); dbDelta($sqall); } } function todays_date() { global $OFFSET; $format = "Y-m-d"; if ($offset) { $nowtime = gmdate($format, time() + 3600*$OFFSET); } else { $nowtime = date($format, time()); } return $nowtime; } function has_viewed($postno, $all) { if ($all == 1) { $temp = explode("&", $_SESSION["a"]); if(!in_array($postno, $temp)){ $_SESSION["a"] .= $postno."&"; return 0; } else { return 1; } } else if ($all == 2) { $temp = explode("&", $_SESSION["n"]); if(!in_array($postno, $temp)){ $_SESSION["n"] .= $postno."&"; return 0; } else { return 1; } } } function todays_count($postnum, $unique) { global $wpdb; global $table_name; if ($unique) { $viewed = has_viewed($postnum,2); } $nowisnow = todays_date(); $checkpost = $wpdb->get_row("SELECT id, postnum, time, postcount FROM $table_name WHERE postnum = '$postnum'"); $postid = $checkpost->id; $postnumb = $checkpost->postnum; $posttime = $checkpost->time; $postcount = $checkpost->postcount; if (!$postid) { $wpdb->query("INSERT INTO $table_name (time, postnum, postcount) VALUES ('$nowisnow', $postnum, 1)"); } else if ($posttime == $nowisnow) { if (!$viewed) { $wpdb->query("UPDATE $table_name SET postcount = postcount+1, time = '$nowisnow' WHERE postnum = '$postnum'"); } } else { if (!$viewed) { $wpdb->query("UPDATE $table_name SET postcount = 1, time = '$nowisnow' WHERE postnum = '$postnum'"); } } $post_c = $wpdb->get_var("SELECT postcount FROM $table_name WHERE postnum = '$postnum'"); return $post_c; } function todays_count_widget($views,$list) { global $wpdb; global $table_name; global $table_posts; $home_url = get_settings('home'); $perma = get_settings('permalink_structure'); $nowisnow = todays_date(); $todays_widget_temp = ""; trim($views)!='' ? ($views = " ".$views) : ($views = ""); ((strtolower($list) == 'ul') || (strtolower($list) == 'ol')) ? $list = strtolower($list) : $list = 'ul'; if ($list == 'ul') {$lbeg = '';} else {$lbeg = '
    '; $lend = '
';} $todays_widget = $lbeg."\n";; $widgets = $wpdb->get_results("SELECT * from $table_name inner join $table_posts on $table_posts.ID=$table_name.postnum WHERE time = '$nowisnow' and postcount > 0 and post_status = 'publish' ORDER BY postcount DESC LIMIT 10"); $widgets_num = $wpdb->get_var("SELECT COUNT(*) FROM $table_name inner join $table_posts on $table_posts.ID=$table_name.postnum WHERE time = '$nowisnow' and postcount > 0 and post_status = 'publish'"); if ($widgets_num) { foreach ($widgets as $widget) { $postnum = $widget->postnum; $postcount = $widget->postcount; $id_post = $widget->ID; $title_post = $widget->post_title; if ($perma) { $home_url_perma = get_permalink($id_post); $todays_widget_temp .= "
  • $title_post ($postcount views)
  • \n"; } else { $todays_widget_temp .= "
  • $title_post ($postcount$views)
  • \n"; } } } if (!$todays_widget_temp) { $todays_widget_temp .= "
  • No posts viewed yet.
  • "; } $todays_widget .= $todays_widget_temp; $todays_widget .= $lend."\n";; echo $todays_widget; } function todays_overall_main($postnum, $visited, $times, $sofar) { global $wpdb; global $table_name; global $table_name_all; $nowisnow = todays_date(); $show_overall_main= ""; $post_c = $wpdb->get_var("SELECT postcount FROM $table_name WHERE time = '$nowisnow' AND postnum = '$postnum'"); $post_d = $wpdb->get_var("SELECT postcount FROM $table_name_all WHERE postnum = '$postnum'"); if ($post_d>0) { $show_overall_main = "$visited $post_d $times"; if ($post_c) {$show_overall_main .= ", $post_c $sofar";} } echo $show_overall_main; } function todays_overall_count($postnum, $visited, $times, $sofar, $unique, $show) { global $wpdb; global $table_name_all; if ($unique) { $viewed = has_viewed($postnum,1); } $checkpost = $wpdb->get_row("SELECT id, postnum, postcount FROM $table_name_all WHERE postnum = '$postnum'"); $postid = $checkpost->id; $postnumb = $checkpost->postnum; $postcount = $checkpost->postcount; if (!$postid) { $wpdb->query("INSERT INTO $table_name_all (postnum, postcount) VALUES ($postnum, 1)"); $show_overall = "Visited 1 times"; $show_today = todays_count($postnum, $unique); } else { if (!$viewed) { $wpdb->query("UPDATE $table_name_all SET postcount = postcount+1 WHERE postnum = '$postnum'"); $postcount_ap = $postcount+1; } else { $postcount_ap = $postcount; } $show_today = todays_count($postnum, $unique); if ($postcount_ap>0) { $show_overall = "$visited $postcount_ap $times"; if ($show_today) {$show_overall .= ", $show_today $sofar";} } } if ($show != 'noshow') { echo $show_overall; } } function todays_overall_count_widget($views,$list) { global $wpdb; global $table_name_all; global $table_posts; $home_url = get_settings('home'); $perma = get_settings('permalink_structure'); $nowisnow = todays_date(); $todays_overall_widget_temp = ""; trim($views)!='' ? ($views = " ".$views) : ($views = ""); ((strtolower($list) == 'ul') || (strtolower($list) == 'ol')) ? $list = strtolower($list) : $list = 'ul'; if ($list == 'ul') {$lbeg = '';} else {$lbeg = '
      '; $lend = '
    ';} $todays_overall_widget = $lbeg."\n"; $widgets = $wpdb->get_results("SELECT * from $table_name_all inner join $table_posts on $table_posts.ID=$table_name_all.postnum WHERE postcount > 0 and post_status = 'publish' ORDER BY postcount DESC LIMIT 10"); $widgets_num = $wpdb->get_var("SELECT COUNT(*) FROM $table_name_all inner join $table_posts on $table_posts.ID=$table_name_all.postnum WHERE postcount > 0 and post_status = 'publish'"); if ($widgets_num) { foreach ($widgets as $widget) { $postnum = $widget->postnum; $postcount = $widget->postcount; $id_post = $widget->ID; $title_post = $widget->post_title; if ($perma) { $home_url_perma = get_permalink($id_post); $todays_overall_widget_temp .= "
  • $title_post ($postcount views)
  • \n"; } else { $todays_overall_widget_temp .= "
  • $title_post ($postcount$views)
  • \n"; } } } if (!$todays_overall_widget_temp) { $todays_overall_widget_temp .= "
  • No posts viewed yet.
  • \n"; } $todays_overall_widget .= $todays_overall_widget_temp; $todays_overall_widget .= $lend."\n"; echo $todays_overall_widget; } function admin_todays_count_widget() { global $wpdb; global $table_name; global $table_posts; $home_url = get_settings('home'); $perma = get_settings('permalink_structure'); $nowisnow = todays_date(); $todays_widget_temp = ""; $widgets = $wpdb->get_results("SELECT * FROM $table_name inner join $table_posts on $table_posts.ID=$table_name.postnum WHERE time = '$nowisnow' and postcount > 0 and post_status = 'publish' ORDER BY postcount DESC LIMIT 10"); $widgets_num = $wpdb->get_var("SELECT COUNT(*) FROM $table_name inner join $table_posts on $table_posts.ID=$table_name.postnum WHERE time = '$nowisnow' and postcount > 0 and post_status = 'publish'"); if ($widgets_num) { foreach ($widgets as $widget) { $postnum = $widget->postnum; $postcount = $widget->postcount; $id_post = $widget->ID; $title_post = $widget->post_title; if ($perma) { $home_url_perma = get_permalink($id_post); $todays_widget_temp .= "
    $title_post
    | $postcount views
    "; } else { $todays_widget_temp .= "
    $title_post
    | $postcount views
    "; } } } if (!$todays_widget_temp) { $todays_widget_temp .= "No posts viewed yet."; } $todays_widget .= $todays_widget_temp; echo $todays_widget; } function admin_rightnow() { global $wpdb; global $table_name; global $table_posts; $home_url = get_settings('home'); $perma = get_settings('permalink_structure'); $nowisnow = todays_date(); //$todays_widget = "