########################################################################################################## # "Top 10 Posts" coded by LaughingLizard http://weblogtoolscollection.com/ # # Compatible with WordPress 1.2 http://www.mindfulmusings.net/weblog/ # ########################################################################################################## 1) Open up mysql command line tool, and type in these lines: (this is considering wpdatabase is the name of your wordpress database) use wpdatabase; create table mostAccessed ( postnumber int not null, cntaccess int not null, primary key(postnumber), unique id(postnumber) ); Or you could use phpMyAdmin or any other MySql admin tool to create a new table called usersOnline inside your WordPress database with the above columns. 2) Copy the functions from below to your my-hacks.php and place it within tags. Make sure "legacy my-hacks" is turned on in your admin interface. function add_count($p_number) { $result = mysql_query("select postnumber, cntaccess from mostAccessed where postnumber = '$p_number'"); $test = 0; while ($row = mysql_fetch_array($result, MYSQL_NUM)) { $row[1] += 1; @mysql_query("update mostAccessed set cntaccess = '$row[1]' where postnumber = '$row[0]'"); $test = 1; } if ($test == 0) { @mysql_query("insert into mostAccessed(postnumber, cntaccess) values('$p_number', '1')"); } } function show_pop_posts() { global $wpdb, $siteurl, $tableposts; $results = $wpdb->get_results("select postnumber, cntaccess from mostAccessed ORDER BY cntaccess DESC LIMIT 10"); foreach ($results as $result) { $postnumber = $result->postnumber; $post = @$wpdb->get_row("SELECT ID, post_title FROM $tableposts WHERE '$postnumber' = ID"); //$post_title = substr($post->post_title, 0, 20); $post_title = $post->post_title; //$url = get_permalink($post->ID); echo "