I just put up a new version on my site. Same location:
to keep things clean, you might want to just include('same_cat.php') into your wp-hacks file. makes it easier to upgrade. ;)
1. I added in the srand, to ensure everyone has it from now on.
2. I added a new param in, after the MAX, RANDOM params, which is a postID to 'ignore'. So you can now do within the posts loop:
echo "<div class='related'>Related Posts:";
echo list_posts_of_cat(get_the_category(), 1, 1, $post->ID);
... and it will filter OUT the current post from the possible responses.
3. At the top of the file are two new globals:
$sameCatDebug = 0;
$sameCatDebugout = '';
if you change the debug to 1, it will accumulate debugging information into sameCatDebugout. You can then do an echo, or write to a logfile, to capture the output. I tested it with
<?php echo "<div id='samecaterrs' style='font: 10px Times, serif'>$sameCatDebugout</div>"; ?>
if you capture the output for me for a few runs, I'll look at it and see if something seems off. The only thing that would cause it is if rand isn't working, or if your total posts in a cat is <= requested amount.
I'll keep banging on it if I can get some debug output from you guys. BTW, watch for "randomize disabled" in the output, as that'll show up in cases where random did get turned off bc of not enough query results. The output should be somewhat self-explanatory if you've read the code at all.