I’ve hacked together a prototype of a Top Posts plugin for WordPressMU.
The concept is to create a global table that stores the blog_id, post_id, and time for each hit to a post/page, and then allows you to get list of the posts with the most hits. This is an early early version.
You can download it here.
Put this php file in your ‘wp-content/mu-plugins’ directory. Sit back and enjoy.
The simple version would be to call:
<?php zap_top_posts_html(); ?>
This will return a <ul>…</ul> block of html.
But you can also use this much like you would use get_posts() in any template. For example, the following should also work…
<ul> <?php $myposts = zap_get_top_posts(); foreach($myposts as $post) : ?> <li><a href="<?php echo $post->guid; ?>"> <?php the_title(); ?></a> [<?php zap_the_post_hits(); ?>]</li> <?php endforeach; ?> </ul>
Anyway, this is just a prototype. I haven’t really done that much testing. I have no idea how well it will perform in general. I know there are a couple bugs in there. As I fine tune this, I will post additional updates.
Known issue: You can’t use the get_permalink() and the_permalink() tags becuase they depend on other global variables that are not properly set up with these functions. If you want the link to the post use $post->guid.