WordPress Plugins Updated: Similar Posts, Recent Posts, Random Posts, and Recent Comments

Finally! I have posted the updated (2.5) versions of my post plugins and they are full of enhancements and even the odd fix… Check them out from the plugins page but please take note:

  • They are still beta releases and, given the number of modifications I have made, I am sure I will have a few issues to correct. If you have any problems try reporting them through the in-built bug-reporting tool. Other comments are, of course, welcome on each plugin’s own page.
  • The plugin code has been substantially refactored to minimise duplication and, as a result, the four plugins now share a library. Please take care to read the upgrade directions rather than blundering ahead (the way I usually do myself!).
  • If you have been using the Plugin Output Cache you will need to update to the latest version.

So … new features, new options, and new output tags … and a few bug fixes as well.

New Features

  • Ready for WordPress 2.5 with a new matching admin interface.
  • Random Posts is about twice as fast as before.
  • Similar Posts has had a lot of work. It now uses its own table instead of using custom fields. Tag-based similarity has been added and the balance between content, title, and tags is fully adjustable. You can now add similar posts to your feeds without an extra plugin (Similar Posts Feed has been discontinued). I have supplied stop lists for English, French, German, Spanish, and Italian (with more to come) — and stemming algorithms to match. I also have plans for various refinements and extensions of the similarity algorithm, including some support for Japanese, Chinese and Korean.
  • When used as widgets the plugins have a new option to only show under certain circumstances by using WordPress Conditional Tags like ‘is_single(), e.g.,
    is_single() && is_paged()
  • The plugin display can now be injected on a post-by-post basis by using embedded tags, e.g., <!--SimilarPosts-->.
  • You can now report bugs from the plugin settings pages and automatically send along basic information to aid debugging, like what version of PHP, MySQL etc. are in use.
  • There is now an option to completely remove the plugins and all their settings without having to fiddle with phpMyAdmin.
  • Increased security with proper nonce-protection and better screening of settings.
  • A much better memory footprint, especially when more than one of the plugins is installed.
  • The plugins are set up for internationalisation … but as of yet not translated.
  • It is now much easier to extend the plugins with your own output template tags.
  • The plugins are much more careful of how they handle multi-byte character sets.

New Options (or settings as WP 2.5 calls them)

  • It is now possible to have no output at all if the plugin finds no matching posts.
  • The fallback text when no posts are listed can now contain embedded output tags.
  • You can now choose to only include posts that are more than, or less than, a certain number of days, months, or years old.
  • A content filter can be turned on to expand tags embedded in posts so that plugin output can be injected on a post-by-post basis.
  • The Recent Comments’ option to exclude certain comment authors (which never worked properly!) has been replaced with the option to omit comments left by the post’s author.
  • It is now possible to include ‘&’ in parameters passed by query-string.

New Output Tags

  • {totalposts} and {totalpages}
  • {postid}
  • {postviews}
  • alternate {commentlink2}
  • alternate {excerpt} preserving HTML etc.
  • a variety of ways to crop {title} etc.
  • {image}
  • {categoryid}
  • {commenterip}
  • and {php} which lets you insert your own code!

Bug Fixes

  • Better validation of settings.
  • Fixed an ordering bug in Recent Comments when grouped by post.
  • Fixed a problem on some systems with ‘include’ of relative paths.
  • No longer troubled by the awkward bug in MySQL version 4.1.21.

That should be plenty to play with!

24 replies on “WordPress Plugins Updated: Similar Posts, Recent Posts, Random Posts, and Recent Comments”

  1. Upgraded both Recent Comments and Random Posts as instructed in preparation for 2.5 (currently using 2.3.3). Options subpages don’t display in either plugin. Downgraded.

  2. Nick: That’s a discouraging start! I have sent you a file with a possible fix to see if it helps. Could you please let me know some server details to help finding the problem.

  3. Hi Rob,

    Fix didn’t work. Just to clarify – Options subpage General displays but each subsequent subpage doesn’t, I’m presented with the WordPress interface header and footer only.

    Apache. MySQL 4.1.2. PHP 4.3.9.

  4. Spoke too soon! The subpages work as expected, but the Random Posts plugin is set to display 10 posts but is outputting either 8, 9, or 10 posts arbitrarily.

  5. Rob,

    Tested Random Posts 2.5 b3a using WordPress 2.5 RC1 on a server running PHP 5.2.5 and MySQL 5.1.23 RC. The plugin continues to output anywhere from 6 to 10 random posts when it’s set to output 10.

  6. Nick: I’ve backtracked to the previous version’s code in 2.5 b4. I really do think it’s working properly now. I hope I don’t have to eat my words again!

    Good luck!

  7. Hi. I’m trying to get the most recent comment for each individual posting, displayed under the corresponding posting in archive view.

    But what I’m getting is the same most recent comment displayed with each posting.

    Is it possible to do what I need with this plugin? It seems so close… Thanks in advance.

  8. Barend: Recent Comments would be overkill for what (I think) you are trying to do. Its intention is do a global listing of comments rather than the comments per post. Maybe the WordPress tag comments_link() would do the job for you?

  9. Hi Rob, thanks for your reply. Yes it seems like overkill. I thought it would be very straightforward to include the last comment with each post. Your suggestion only puts a link to the comments below the post. What I’d like to achieve is the following:

    ” Post A”
    latest comment on Post A

    “Post B”
    latest comment on Post B

    etc.

    I hope I’m missing something really obvious here, so any help is appreciated.

  10. Barend: It rather depends on how you are generating the post listing but the following code will get the last comment from a post ID:

    
    function get_latest_comment($post_id) {
    	global $wpdb;
    	return $wpdb->get_var($wpdb->prepare("SELECT comment_content FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' ORDER BY comment_date LIMIT 1", $post_id));
    }
    

    Let me know if this helps.

  11. Rob: thank you so much for thinking along. I’m in slightly over my head I’m afraid. I’m guessing i need to place that code into functions.php, and then how exactly do I call that function in the “loop”? If you want to take this off this list you’ve got my email address I’m sure.

  12. Dan: Can you try re-indexing the posts via the Manage|Similar Posts screen? There seems to be a serious issue here that I’d like to solve.

Comments are closed.