This posting is now outdated… for the latest information on YARPP, please visit YARPP’s very own page on my site, or its page on
wordpress.org. If you have questions, please submit on the
wordpress.org forum. Thanks!
Today I’m releasing Yet Another Related Posts Plugin (YARPP1) 1.0 for WordPress. It’s the result of some tinkering with Peter Bowyer’s version of Alexander Malov & Mike Lu’s Related Entries plugin. Modifications made include:
- Limiting by a threshold: Peter Bowyer did the great work of making the algorithm use [[mysql]]’s fulltext search score to identify related posts. But it currently just displayed, for example, the top 5 most “relevant” entries, even if some of them weren’t at all similar. Now you can set a threshold limit2 for relevance, and you get more related posts if there are more related posts and less if there are less. Ha!
- Being a better plugin citizen: now it doesn’t require the user to click some sketchy button to
alterthe database and enable a
fulltext key. Using
register_activation_hook, it does it automagically on plugin activation. Just install and go!
- Miscellany: a nicer options screen, displaying the fulltext match score on output for admins, an option to allow related posts from the future, a couple bug fixes, etc.
Just put it in your
/wp-content/plugins/ directory, activate, and then drop the
related_posts function in your WP loop. Change any options in the Related Posts (YARPP) Options pane in Admin > Plugins.
You can override any options in an individual instance of
related_posts using the following syntax:
Most of these should be self-explanatory. They’re also in the same order as the options on the YARPP Options pane.
related_posts(10, null, 'title: ') changes the maximum related posts number to 10, keeps the default threshold from the Options pane, and adds
title: to the beginning of every title.
There’s also a
related_posts_exist() function. It has three optional arguments to override the defaults: a threshold, the past only boolean, and the show password-protected posts boolean.
For a barebones setup, just drop
<?php related_posts(); ?> right after
<?php the_content() ?>.
On my own blog I use the following code with
</li> as the before/after entry options:
Coming soon (probably)
- Incorporation of tags and categories in the algorithm. I’ve gotten the code working, but I still need to think about what the most natural algorithm would be for weighing these factors against the mysql fulltext score currently used (and works pretty well, I must say).
- Um, something else! Let me know if you have any suggestions for improvement. ^^