Post Stumbler WordPress plugin
I’m releasing a plugin which I’ll call the Post Stumbler WordPress plugin (originally to be called the “Stumble Upon” WordPress plugin, but it doesn’t use Stumble Upon at all – even though it tries to mimic its functionality) because that will help most people to understand what it does.
After building this, I found a post that was made over at TechCrunch which discusses about how it would be interesting if WordPress could have similar functionality to what Stumble Upon provides, so I hope that this fulfills that need.
What it does
It basically adds functionality to your WordPress blog which allows visitors to view a randomly selected post on your blog, with a higher probability of choosing popular posts, and with the option of only showing recent posts. You also have the option of giving recent posts more chances to be shown to visitors if you think that your most recent posts are more interesting to your visitors.
Example
To see how this works, click on the links in the sidebar on this page which say “random post” and “random recent post”, which are right below the search box. They are self-explanatory.
How to install
The plugin does have a requirement, which is the Popularity Contest WordPress plugin (install it like any other plugin; just upload it to your /wp-content/plugins/ directory and then activate it in your admin panel), so go and install that first.
When that’s done, download and install my plugin like a normal plugin, too. And you’re done! No configuration is required.
There are two important links that you need to link to. They are:
- http://www.yourblog.com/?stumble
- Replace yourblog.com with your own blog’s URL, of course. This URL will show the visitor a random post but it gives a higher weight to popular posts, which increases the chances that visitors will land on a popular post. This is a really cool way of hand-holding your visitors to the great posts on your blog, without linking them to specific posts.
- http://www.yourblog.com/?stumble&date
- Again, replace yourblog.com with your own blog’s URL. This URL will point your visitor to a random post, again, based on the post’s popularity, but also, based on how recent the post is. More recent posts will have a higher chance of being shown to your visitors. This is especially useful for blogs where posts are more news- and events-based, such as TechCrunch. It is more interesting to read posts that have been written in the past month rather than posts that have been written a few years ago on blogs such as these.
Anyways, please, PLEASE let me know how well this works for you. I have only tested this on a handful of blogs, and so far, it has worked great on them. But, if this plugin brings up posts on YOUR blog that are not popular at all, then do let me know! I’ll try my best to fix them ASAP.
So, I hope you enjoy this plugin!
History
- 07/07/15 – 1.0
- plugin release
Popularity: 38% [?]
Trackbacks
Use this link to trackback from your own site.


Cool plugin. My favorite part of open source is having people point out the things I overlooked in my code, so I have a few comments that might help you improve a future version:
In the first SQL statement, you are asking mysql to send back the entire row for each post in the database, including the post body, and a bunch of other information you don’t need. On a busy blog with lots of posts, this might slow things down a bit.
I’m not sure how the popularity contest table is structured, but wouldn’t $total be the same as $total_popularity?
$total_posts seems to only used in the else block, maybe the value could be retrieved in the else block as well to save an unnecessary SQL query?
In the if block,
(($pop->date - $first_date) / $date_diff) * ($date_diff / $pop->date)
could be written as
($pop->date - $first_date) / $pop-$gt;date
The elements in $big_array for the else block could be post ids, like in the if block, instead of as arrays.
It would be more efficient if you krsorted and popped (array_pop) a value from the $big_array after each value was added (except the first one), instead of sorting a huge array at the end. Or if you stored $max_post_id and $max_post_weighted_value (with less verbose variable names, of course) and compared each post’s weight to them, replacing the $max… variables with the current post’s id and weighted value if it’s weighted value is greater.
Overall, there is nothing urgent here, just some things to keep in mind in the future if you choose to.
Keep up the great work.
I made a little typo,
($pop->date - $first_date) / $pop-$gt;date
should read
($pop->date - $first_date) / $pop-$>date
Gah, I did it again. I meant to say:
($pop->date - $first_date) / $pop->date
Paul, thanks for the comments. I’ve updated the plugin a bit to incorporate some of your suggestions.
[...] Post Stumbler adds functionality to your WordPress blog which allows visitors to view a randomly selected post on your blog, with a higher probability of choosing popular posts, and with the option of only showing recent posts. [...]
[...] by Matt Mullenweg which weighs all posts evenly and allows you to find a post at random, or the Post Stumbler plugin, which does the same but does a better job of mimicking StumbleUpon, by allowing users to in theory [...]
[...] Plugins Page | Download [...]
I gave this plugin a try, but every time I clicked on the stumbling link it would always bring me to my latest post. It wouldn’t stumble anything else.
[...] Post Stumbler WordPress plugin | King Gary [...]
[...] Visit [...]
[...] Source Code syntax highlighting plugin за WordPress FeedBurner FeedSmith Link Harvest на Alexaking Google Translate Wordpress Plugin Feed Statistics plugin Post Stumbler WordPress plugin [...]
Very nice. Worked right first time, just as all plugins should. Thanks.
Great plugin, thanks! Just one question: how did you get the “Popular in past 30 days” in your sidebar? The “Popularity Contest” documentation doesn’t seem to have such a function — just akpc_most_popular() and akpc_most_popular_in_cat() — neither of which has a “last 30 days” option.
Thanks!
This is a great plugin. This type of is priceless for the new kid on the block.
Thanks
Vic
Thanks for the great plugin. I’ll be installing it on my three blogs right away.
[...] Cron Job. I think Textile Plugin Moved To Wordpress Plugin Directory is worthy. Take a look at Post Stumbler WordPress plugin. It was admirable to get a lot from Utilizing the Wordpress More Tag. ?Test shouldn’t be [...]
This is a great plugin.