########################################################################################################## # "Top 10 Posts" coded by LaughingLizard http://dinki.mine.nu/word/ # # Compatible with all versions of WordPress 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) If you are using WordPress 1.0 or above AND are using my-hacks.php, copy the functions from below to your my-hacks.php and place it within the tags. If you are using 0.72 or below, copy these to the end of your b2functions.php which is inside your b2include folder; again make sure that they are within the tags. 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 "