Similar Posts

Purpose

This plugin displays a list of posts which are related or similar to the current post.

This is version 2.5.0 download latest version. It is compatible with WordPress 1.5–2.5.

Please note the new upgrade instructions!

2.5.0 improves the CJK matching algorithm by using bigrams. Also introduces a new output tag {imagesrc}, and adds more parameters to {image}. Fixes bugs with empty categories, excluded posts, and the option to omit current posts. 2.5b28 improves the matching algorithm and adds an experimental mode for blogs in Chinese, Korean, or Japanese. 2.5b27 fixes a bug with the bulk indexing of tags. 2.5b25 makes some important changes: the {image} output tag now serves real thumbnails (couple of bug fixes too); output can now be sorted as you choose with sub-headings included; the {date:raw} tag modifier has been added to help the sorting; the ‘trim_before’ option has been replaced with the more logical ‘divider’. 2.5b24 fixes to stop recursive replacement by content filter, {gravatar} to allow for ‘identicon’ etc., to {commenter} to allow trimming, and to remove a warning in safe mode 2.5b23 brings a new option to filter on custom fields and adds proper nesting of braces in {if}. 2.5b22 moves the manage menu under settings as a subpage, restores automatic indexing on activation, fixes conflicts with the legacy Similar Posts Feed plugin, fixes bugs in several output tags, and introduces the option to show only pages. 2.5b20 doubles the speed of indexing and reduces the memory footprint considerably. 2.5b19 fixes a bug when snippets are stripped of extra tags. 2.5b18 fixes a problem with filtering the output and introduces the conditional tag {if:condition:yes:no}. 2.5b16 fixes a problem with {php}. 2.5b15 fixes for some more installation problems, one or two bugs, and adds the ‘included posts’ setting. 2.5b14 fixes for some of the kinds of installation problems. 2.5b11 fixes some widget problems. 2.5b10 fixes (some?) of the problems folks have been having with no posts found. Most of such errors seem to arise when the proper table is not created and this version addresses that. 2.5b9 has new features and improvements. 2.3.6 restores the widgetiness I managed to remove in 2.3.5! 2.3.5 has been rebuilt to save memory and can match the current post’s tags. It also fixes a bug with categories in WordPress < 2.3. 2.3.4 now works as a widget. 2.3.3 beta adds the ability to include as well as exclude categories and authors and is able to find posts by tag. 2.3.2 beta fixes a conflict between tags and categories. 2.3.1 beta fixes a stupid bug in category exclusion. 2.3.0 beta is compatible with WP 2.3, fixes the {author} bug, and a number of problems related to versions of MySQL. 2.1.1 beta fixes a badly chosen fallback value for the number of terms used to match similar posts.

Ideally, similarity or relatedness would be based on a post’s meaning. Tagging systems try to add meaning after the fact but suffer from two deficiencies, one practical and the other theoretical. When a blog already has many posts it can be impractical to retrofit a tagging system by tagging every post by hand. ‘Automatic’ services, like Yahoo’s, tend to produce too many suggestions which need to be culled, again by hand.

The theoretical problem with tagging is that it tries to pin down a meaning for a post by categorising it under a small number of types, whether those types belong to a predetermined hierarchy or arise by ‘folk’ classification. In fact, a post has a variety of meanings, a multitude of ways it can be related to other posts. Meaning doesn’t just lie in the intention of the author or in the classification of the reader; meaning also inhabits the text itself. Meaning is in the words.

The Similar Posts plugin compares posts by comparing their words. MySQL has a sophisticated full-text searching facility with a carefully tuned algorithm for judging the similarity between texts. Similar Posts extracts representative words from a post’s content, title, and tags and uses the full-text index to find the best matches between posts. This simple approach gives surprisingly good results.

The results can be tweaked in several ways to tailor them for you blog. By default the plugin chooses the 20 most frequent words to make its matches but the number is adjustable. It is worth experimenting to see how many words gives the best results for your blog — it has hardly any impact on speed, even if you set the value high enough to include the whole post. The relative importance given to words in your title may be adjusted so that well-chosen titles can be used to advantage or titles with little relevance downplayed. Similarly, tags can be used to improve matching or not according to your blog and it’s needs.

The plugin has a settings page which lets you change how the output is generated and displayed. There is also a management page where you can change settings which affect the index.

Installation Instructions

If upgrading from a previous version, first deactivate the plugin via the Plugins page and delete the plugin folder from your server. If you have been using the Similar Posts Feed plugin you should deactivate it as it is now obsolete. Upload the plugin folder to your /wp-content/plugins/ directory. You will also need to install the Post-Plugin Library. Go to your admin Plugins page and activate Similar Posts. This will automatically add a new table to enable fast, flexible full-text matching. If the plugin reports that there was a problem creating the table first try deactivating and reactivating the plugin. Put <?php similar_posts(); ?> at the place in your theme files where you want the list of similar posts to appear. Lorelle on WordPress has a good guide to modifying themes for plugins. If you are using a widget-ready theme the plugin can be placed from the widget admin page. Use the admin Settings|Similar Posts pages to set all the available options. Alternatively, the options can be overridden by passing a parameter to the similar_posts template tag.

Usage and Options

The configuration page will help you to set up the plugin to your satisfaction.

The Index Management Page

Using this settings subpage you can re-index your blog. There are two main settings which affect the indexing.

PHP is, by default, not very good at handling text that isn’t in English and you might find Similar Posts mangles extended characters. If so, you can get the plugin to use PHP multi-byte string library if it is available.

The second setting attempts to handle words with related meanings. For example, ‘animal’ and ‘animals’ should probably not count as two distinct words, nor ‘follow’, ‘follows’, ‘following’, etc. You can choose to build the index using a stemming algorithm that groups such words as one (if there is one available for your language).

A third, experimental, setting is for blogs written mainly in Chinese, Korean, or Japanese. The MySQL fulltext index used by Similar Posts has problems with these languages but this setting tries several ways to work around the issues. The setting currently only works when posts are encoded as UTF-8. I would be very glad to get opinions from users familiar with these languages.

To avoid excessive memory use the indexing routine processes posts in batches of 100. This figure can be reduced to shrink the memory consumption even further.

Language Issues

The underlying MySQL full-text indexing is obviously very locale-dependent — how words are divided or punctuation handled, what words are treated as noise, etc. all vary from language to language. For the Similar Posts plugin to work well the version of MySQL on your server must be properly setup in the appropriate language.

Similar Posts generates the terms it matches on by analysing the word frequency of a post while ignoring the most common ‘noise’ words — in English, words like ‘of’, ‘and’, ‘across’, ’someone’, etc. It uses a so-called ’stop list’ of common English words to ignore. In fact it uses the stop list a standard English installation of MySQL uses. Obviously this list will be useless for other languages so Similar Posts makes the stop list pluggable.

The Similar_Posts folder contains a subfolder, ‘languages’, with stop lists and stemmers for a German, English, French, Spanish, and Italian. The plugin checks the WPLANG constant (defined in wp-config.php) to see which language WordPress is using and looks for a file on that basis. If WPLANG is undefined or the appropriate file cannot be found the default English list is used.

If you are looking for help setting up a stop list in a language other than English a good resource can be found at http://www.ranks.nl/tools/stopwords.html. Stemmers in PHP are harder to come by. You can work out how to adapt any you find by inspecting the provided stemming files.

Finally…

I look forward to your help in ironing out any issues and implementing any good ideas. The plugin settings page has an option to submit bug reports but general comments can be left below.

Frequently Asked Questions

Rating: +0


Positive


Negative

I’ve just upgraded to Similar Posts version 2.5 and it can’t find any matching posts: all I see is ‘None Found’.

This is probably because the necessary database table was not created for some reason. Make sure you have the latest version of Similar Posts. Try deactivating and then reactivating.

If that still fails try creating the table manually using the SQL below (for example in phpMyAdmin):

CREATE TABLE IF NOT EXISTS `wp_similar_posts` (
`pID` bigint( 20 ) unsigned NOT NULL ,
`content` longtext NOT NULL ,
`title` text NOT NULL ,
`tags` text NOT NULL ,
FULLTEXT KEY `title` ( `title` ) ,
FULLTEXT KEY `content` ( `content` ) ,
FULLTEXT KEY `tags` ( `tags` )
) ENGINE = MyISAM CHARSET = utf8;

If your table prefix is not ‘wp_’ change the code above to match. If the above query causes an error try:

CREATE TABLE IF NOT EXISTS `wp_similar_posts` (
`pID` bigint( 20 ) unsigned NOT NULL ,
`content` longtext NOT NULL ,
`title` text NOT NULL ,
`tags` text NOT NULL ,
FULLTEXT KEY `title` ( `title` ) ,
FULLTEXT KEY `content` ( `content` ) ,
FULLTEXT KEY `tags` ( `tags` )
) ENGINE = MyISAM;

Make sure you reindex after creating the table.

Rating: +0


Positive


Negative

I’m trying Similar Posts on a new site. Everything seems to be properly installed but it says ‘None Found’ when I know there should be matches.

If it is a new site you probably only have a few posts so far. The way the database searches for matches can seem a little strange when there aren’t many posts. For example any words found in more than half the number of posts are ignored. Remember, too, that only words longer than three letters are counted.

I recommend you add a number of real, different, and normal-sized posts and you should begin to see Similar Posts working correctly.

Another possible cause for few or no matches showing is that your settings may be too restrictive, in particular opting to match categories and/or match tags can really narrow down the chances of a match. Try less demanding settings — if you want to reset the default options you can remove the plugin from the settings menu and then reactivate.

Rating: +0


Positive


Negative

I get some strange values for {score}. Sometimes it’s well over 100 and sometimes it can be as small as 8 or 9 for posts that seem quite similar.

MySQL reports only the relative similarity of posts rather than some absolute number. The score depends on a number of factors. I have tried to scale the value of {score} so that it is very roughly 100 for a post’s similarity to itself — but even that is affected by too many variables to be more than a rough estimate.

Rating: +0


Positive


Negative

How do I include a list of similar posts in my feeds?

Just switch on the option (Settings|Similar Posts|Other) to add Similar Posts to feeds. A new settings menu will appear with a full set of options for the feed.

Rating: +0


Positive


Negative

Why, when I use Similar Posts as a widget, does it always gives the same list of posts?

You are probably using a WordPress version below 2.5 and one of the built-in widgets like Recent Posts or Recent Comments. Both widgets do their work by running a a new wp_query and in the process they destroy the context Similar Posts needs to function correctly. I thought this has been fixed in WordPress 2.5 but maybe not.

One workaround is to replace the built-in widgets with my own ;-)

Rating: +0


Positive


Negative

Where have my keywords gone to? I can’t find the custom field ’similarterms’.

Version 2.5 uses a separate table rather than custom fields. If you are looking to influence similarity consider tagging your posts.

Rating: +0


Positive


Negative

How do I get it so that {link} displays the date instead of the title? If i use the {date} template tag, it shows the date but no link.

You need to use the output template to tell the plugin exactly what to display. For example, if you want a link where the visible text shows the date of posting you could try:


<li><a href="{url}">{date}</a></li>


Rating: +0


Positive


Negative

How do I format the output of the {date} tag?

The blog’s date format is used by default but you can change it by adding a format string. The Codex has a page on format strings. Let’s say you want the date to look like Sunday, January 14, 2007. The correct format string is ‘l, F j, Y’ so you would write

{date:l, F j, Y}

Rating: +0


Positive


Negative

I don’t want my post plugin widget to show on the main page, just the single post page. Is that possible?

Yes. The widgets now let you choose the condition under which they are visible. The condition can be set using any combination of WordPress Conditional Tags, e.g., ‘is_home()’, ‘is_category()’, or ‘is_page()’.

In this case the right condition is ‘is_single()’.

Rating: +0


Positive


Negative

I’m trying to place the plugin output just after a single post but other plugins seem to get in there first. Any ideas?

Some plugins automatically tack on their output to the end of a post’s content. The only way to get something in between is to hope that those plugins offer a way to turn off that kind of behaviour and let you explicitly place their output with a template tag. The good news is that most plugins are cooperative.

Rating: +0


Positive


Negative

I found a script that allows me to put thumbnail images [or anything else] with each post. I was wondering if there was a way to integrate that with this plugin?

If the script stores the thumbnails in a custom field you can use the output template tag {custom} to display them. Try
something like:


<img src="{custom:thumbnail}" alt="{custom:thumbnail-alt}" />

A similar thing can be done with many other plugins.

Rating: +0


Positive


Negative

I want to show the same plugin in two different places but with different output: can I?

Yes. Decide on one of the output templates and other settings you need and set them up from the options pages. The other invocation of the plugin then gets called with passed parameters to get the different output.
e.g., random_posts('limit=3&output_template={custom:another_field}')

Rating: +0


Positive


Negative

I want an output template tag to do xxxxxx. How do I invent one?

You have two choices: a) modify the output_tags.php in the post-plugin-library; b) use the {php} tag.
If you go down route (a) (which is actually very easy) please let me know the new tag and I’ll maybe include it in the next version. If you use the {php} tag do be careful not to start WWIII.

Rating: +0


Positive


Negative

I uninstalled one of your plugins and now my whole sidebar has disappeared. How do I get it back?

You have probably forgotten to remove the code calling the plugin, e.g., recent_posts();.
I find a good practice is to use something like:


if (function_exists('recent_posts')) {
  recent_posts();
}

That way, if I ever deactivate a plugin temporarily the website doesn’t fall apart.

182 Comments Add your own

1. Rob  |  March 6th, 2008 at 10:07 pm

Sukarto: I hope so! Try adding several different ‘real’ posts (i.e., with plenty of real words) and I hope that proper matching behaviour will follow. If it doesn’t we will have to work out what the strange difficulty is.

2. Tanguillo  |  March 18th, 2008 at 6:40 pm

Ok, when I activate the plugin, in wordpress 2.5 rc1 it shows me this weird, weird error, after says can not activate the plugin:

Fatal error: Cannot redeclare similar_posts() (previously declared in /home/tangosco/public_html/wp-content/plugins/similar-posts/similar-posts.php:33) in /home/tangosco/public_html/wp-content/plugins/similar-posts/similar-posts.php on line 33

More weird is that the plugin is actually activated, and the both menu options are working (And I have to tell you it look great)… But in my post it seems it doesn’t find any similar article.
Let me know what other info I can give you to solve this.
Thanks!

3. Rob  |  March 18th, 2008 at 9:06 pm

Tanguillo That is certainly weird! Can you tell me if the wp_similar_posts database table has been created?

If it has try using the Manage Similar Posts menu to reindex and see if that helps…

Oh and did you deactivate and remove the old version before upgrading?

Let me know…

4. Tanguillo  |  March 18th, 2008 at 9:17 pm

Well, that works!!!
I mean, it still give me that error if I deactivate it/activate it, but after the reindex, my post show the similars post, and it seems very good.

The only think that I did wrong the first time wast to try to activate it without copy the post-plugin-library folder first. It give an error, of course. Could be that the problem? Or maybe is a problem with the 2.5 version?

5. Rob  |  March 18th, 2008 at 9:36 pm

Tanguillo: I guess the activation ended strangely and left WP in a halfway state where the database table was installed but not indexed. I don’t know how to solve the activation issue apart from suggesting you deactivate and completely remove the plugin folders, check the plugin page is working and then reupload and reactivate. I have occasionally had similar tangles with other plugins if I tried renaming a folder while the plugin was activated.

Let me know of any other problems.

6. Rob  |  March 22nd, 2008 at 10:03 am

Version 2.5 b4 fixes a problem with empty posts.

7. Josette  |  March 22nd, 2008 at 5:53 pm

Hi! I’ve just tried to install this Similar post plugin. When I want to activate it, it couldn’t be activated at all because it triggered a fatal error!

This message appeared:

Warning: require_once(/home2/childcec/public_html/bookslm//wp-content/plugins/post-plugin-library/output_tags.php) [function.require-once]: failed to open stream: No such file or directory in /home2/childcec/public_html/bookslm/wp-content/plugins/similar-posts/similar-posts.php on line 45

Fatal error: require_once() [function.require]: Failed opening required ‘/home2/childcec/public_html/bookslm//wp-content/plugins/post-plugin-library/output_tags.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home2/childcec/public_html/bookslm/wp-content/plugins/similar-posts/similar-posts.php on line 45

I really like this plugin and hope I can continue using it! Thank you.

8. Rob  |  March 22nd, 2008 at 6:23 pm

Josette: Did you upload the post-plugin-library folder as well as the similar-posts folder?

9. Bernd  |  March 23rd, 2008 at 2:23 pm

Hi,
I would download thid very nice plugin from the Wordpress Plugin page http://wordpress.org/extend/plugins/similar-posts/
I got an 404 Error.
Maybe you can repair it? ;-)

10. Rob  |  March 23rd, 2008 at 2:35 pm

Bernd: Sorry about that. I am in the process of setting up the official plugin pages for the post plugins. It should be fixed shortly.

11. Josette  |  March 23rd, 2008 at 2:46 pm

Hi Rob! I just moved the post-plugin-library folder and similar post folder to my plugin directory and everything is working well now. Thanks! =D

12. Wolfgang  |  March 24th, 2008 at 12:30 am

Hi Rob! I had Version 2.3.6 installed (WP 2.3.3/German) and everything was perfect. I now wanted to install 2.5 b5 and did this exactly as described (deactivated it, removed the folder, uploaded the new one with post plugin library) and activated it.
But there where no similar posts found. Every post had a “None found” under it. Tried to change some setting but without success. Re-indexed - no success. Deinstalled the plugin completely and re-installed it again - no success. Again completely deinstalled it and went back to the old version 2.3.6 which still works fine.
Any idea? Greetings Wolfgang

13. Rob  |  March 24th, 2008 at 8:51 am

Wolfgang: That’s very disturbing! Did you download from this site or from the wordpress.org plugin site? If from the external site, did you also download the Post-Plugin Library plugin? I set up the downloads yesterday and I am having problems getting the proper instructions to show…

I’d be grateful if we could track down this issue.

14. knowlimit  |  March 24th, 2008 at 3:02 pm

Keep getting this error message when I attempt to enter Similar Posts options: Fatal error: Class ‘admin_subpages’ not found in /home/.neo/site/site.com/blog/wp-content/plugins/similar-posts/similar-posts-admin.php on line 44.

I have followed the instructions deactivated, deleted folder, uploaded both folders plugin (version 2.5 b5) and library into the plugins directory.

I’ve deactivated, removed folders (plugin and library) and reloaded with no success.

WP 2.3.3

Please help.

15. Wolfgang  |  March 24th, 2008 at 4:23 pm

Well, even tried Version 2.5 b4 from this site and 2.5 b5 from wordpress.org. Always installed the Post-Plugin Library, which was only shown as plugin with b5. I tried it with php4. Do you think I should try it with php5 on my webserver? Might there be a problem?

16. Rob  |  March 24th, 2008 at 4:28 pm

knowlimit: Have you activated the Post-Plugin Library from the Plugins page? It should happen automatically … Can you check on the Plugins page. There should be an entry for Similar Posts and an entry for Post-Plugin Library.

Thank you for reporting this. It really helps to work towards getting this right.

17. knowlimit  |  March 24th, 2008 at 4:43 pm

Similar Posts is activated.

There is not an entry to activate Post-Plugin Library at wp-admin/plugins.php.

The Post-Plugin Library folder is located at site.com/blog/wp-content/plugins/post-plugin-library (the four files are inside the folder.

Both folders are CHMOD 664.

18. Rob  |  March 24th, 2008 at 5:02 pm

knowlimit: I think I see! Can you download a fresh copy of the Post Plugin Library and try that?

19. knowlimit  |  March 24th, 2008 at 5:26 pm

Rob,

After I uploaded the new PPL folder, I checked my plugin page and noticed that the PPL plugin was already activated.

Similar Posts, as well as Random Posts, is now working perfectly.

Thanks for your assistance, and plugins.

Thomas.

20. Rob  |  March 24th, 2008 at 5:35 pm

Wolfgang: Can you follow these links to download the latest versions of both Similar Posts and the Post Plugin Library and then let me know how things stand and we can work out from there what the problem is.

21. Wolfgang  |  March 25th, 2008 at 12:40 am

Did as requested, but still the same: “None found”. Went again back to the working version 2.3.6.

22. azz  |  March 26th, 2008 at 6:02 am

Just a feedback.

WordPress 2.3.1
Operating System : Linux
Server : Apache
MYSQL Version : 5.0.51a-community
PHP Version : 5.2.1
Post-Plugin Library: 2.5b11
Similar Posts: 2.5b9
Download from wordpress.org

How i do it:
Deactivate previous plugin version
Similar Post –> Post-Plugin Library
Delete plugin folder from hosting server
Upload new version and activate plugin
Post-Plugin Library–>Similar Post
Working great, no problem at all
very nice plugin,

Hope this will help others

Thanks Rob

23. Rob  |  March 26th, 2008 at 7:53 am

azz: Thank you.

24. Rob  |  March 26th, 2008 at 4:46 pm

Wolfgang: 2.5b10 may address the problem you’ve been having–at least it has worked for several other people.

25. Wolfgang  |  March 26th, 2008 at 5:52 pm

Yes! It works now! What was the problem?
Love the new options. The plugins brings now even better similar results. Great! Keep up the good work!

26. Rob  |  March 26th, 2008 at 6:32 pm

Wolfgang: Thanks. The problem was that the database table creation code failed under certain configurations. I’ve tried to make it as innocuous as I can and provided a fallback for versions of MySQL pre-4.1. I hope it will solve all those ‘none found’ issues.

27. Wolfgang  |  March 26th, 2008 at 8:02 pm

Just clicked through a a few tens of posts and the similar posts really look good :-)

28. Rafael Arcanjo  |  March 27th, 2008 at 11:38 pm

I had an error:

Plugin could not be activated because it triggered a fatal error.

I’d installed Post-Plugin Library 2.5b11 and couldn’t use the Similar Posts 2.5b10.

Wordpress 2.3.3

29. Rob  |  March 27th, 2008 at 11:56 pm

Rafael: Can you tell me the versions of PHP and MySQL you are using? Can you tell me if the database table ‘wp_similar_posts’ has been created? Thanks.

30. Leona  |  March 28th, 2008 at 8:48 am

Hi I have the same fatal error problem too. No database wp_similar_posts were created. Am I supposed to create it manually? No rite? I’m using WP 2.2.2

31. Rob  |  March 28th, 2008 at 10:36 am

Leona: The creation should happen automatically but in some cases it is not. Could you try and create the database manually and let me know what the error message is that appears? The sql command can be found in the first question of the FAQ above…

Also can you tell me your PHP and MySQL versions, etc. If you don’t know them have a look on the Similar Posts menu (if you can get to it!) and send me a bug report — it will tell me those details.

Thanks for your time and effort — it really helps to make the plugin work for everyone.

32. Ben Chun  |  March 30th, 2008 at 5:34 pm

Hi Rob — I jumped versions from 2.0.14 beta all the way up to 2.5b11. I deactivated the old one first and made sure to install the Post-Plugin Library and the Plugin Output Cache before installing and activating the new plugin. However, when I activate the new plugin I get:

Fatal error: Call to undefined function get_object_term_cache() in /www/blog/wp-content/plugins/similar-posts/similar-posts.php on line 471

I’m on WP 2.1.3 and PHP 5.2.5. The wp_similar_posts table is correctly created, but remains empty.

Any ideas? Something left over from the old plugin messing me up? (Like the “similartems” entries in wp_postmeta?) Or something else I forgot to install? Thanks in advance.

33. Kes  |  March 30th, 2008 at 5:37 pm

Can this plugin display just recent posts by category. I don’t want it to search and all that. I just want it to display the recent posts under a article that all belong to the same category.

34. Keko  |  March 30th, 2008 at 6:03 pm

Hi Rob, and thanks for your Wp plugins, they make my job easier and my blog more usefull.

Excuse my english, I’m from Spain.

Now the problem:

I deactivated post plugin library and Similar posts, then I updated my blog to WP 2.5 and download the new version of both plugins. When I try to activate then an error message appears:

Fatal error: Cannot redeclare similar_posts() (previously declared in D:\inetpub\webs\kekopontecom\public\wp-content\plugins\similar-posts\similar-posts.php:33) in D:\inetpub\webs\kekopontecom\public\wp-content\plugins\similar-posts\similar-posts.php on line 33

¿Any Idea? Thank you very much, Rob!

35. Tanguillo  |  March 30th, 2008 at 6:09 pm

I still have the same problem as Keko, even after download the last version and erase the old ones.
The plugins activate, but In the site, it shows me the message “Post-Plugin Library missing”.

36. Rob  |  March 30th, 2008 at 6:35 pm

Kes: My Recent Posts plugin will do the trick.

37. Rob  |  March 30th, 2008 at 7:07 pm

Keko & Tanguillo: I am mystified as to why this happens. It is like the plugin is already installed and it see similar-posts() being defined twice!

This is my best advice… give it a try and see if it does anything. If you can get to the similar posts options page use the option there to completely remove the plugin. The delete both the similar posts and the post plugin library folders.

Make sure the plugins page shows they have gone.

Try deactivating and reactivating another plugin.

Then upload the post plugin library and activate it.
Then upload similar posts and activate it.

If the problem doesn’t go away get back in touch. We can try some changes until we get it working but without knowiing the cause it is frustrating.

38. Keko  |  March 30th, 2008 at 7:25 pm

It worked for me!
I just remove the plugin in the options page and then reactivate it. Don’t need to upload them again.

Thank you very much Rob!

39. Rob  |  March 30th, 2008 at 9:15 pm

Keko: I’m glad it worked eventually. I just wish I could figure out why the error occurs in the first place.

40. Rob  |  March 30th, 2008 at 9:17 pm

Ben Chun: Glad to hear the changes got the plugin working again. The next beta contains fixes for versions of WordPress before 2.3 introduced native tagging.

41. mrdeus  |  March 30th, 2008 at 9:49 pm

Hi!

First of all: thank you for a great plug-in!

An issue I’ve been having is that when I write a post I usually write a draft and then edit it some times before publishing it, saving the post between each edit to see the updated preview. It seems that the similar post keywords only are extracted on the first save and aren’t updated when I finally publish the post. Is there a way to force the plugin to re-extract the keywords?

I’m running WP 2.0.5 and similar posts 2.3.6

42. Rob  |  March 31st, 2008 at 12:50 am

mrdeus: For your version you can delete the custom field with the keywords and they will be regenerated on the fly.

I’ll look into the underlying problem.

43. Tanguillo  |  March 31st, 2008 at 1:28 am

It work! :)
As keko says, no need to remove the files. Thanks for the advice!
No I’m happy ;)

44. mrdeus  |  March 31st, 2008 at 1:00 pm

Thank you! That worked like a charm.

45. Rob  |  March 31st, 2008 at 2:33 pm

Excellent plugin.

I’m having an issue with the Similar Posts plugin displaying the same post on every page. It only does it if I have the “Recent Posts” (built-in) widget above your plugin.

I read your FAQ and you say this is fixed in Wp2.5 (which is what I’m using), could you shed any light on the matter?

Rob

46. Rob  |  March 31st, 2008 at 2:38 pm

Rob: Well… I thought WordPress 2.5 had corrected the issue. Similar Posts needs to know the ID of the visible post it is looking for matches to. The problem is that the built-in Recent Post widget runs its own database query and wipes out that information. I thought that the new version restored its context when it was finished but apparently not.

All you can do is invert the order or switch to my own Recent Posts plugin ;-)

47. Tanguillo  |  March 31st, 2008 at 4:35 pm

Hi Rob. I upgrade the plugin to the last version, using the automated method, and it show me the “Fatal error” message again.
I went to my site and it was a “No related post found” message.
But I re-index and all work again.
If I can help you to fix this issue, let me know.

48. Terry Walsh  |  March 31st, 2008 at 10:38 pm

Here too….

49. Rob  |  March 31st, 2008 at 11:46 pm

Terry Walsh: If you can get to the similar posts bug report screen can you send me a report. Otherwise can you let me know the versions of PHP, MySQL, etc. and any other details you think might be relevant. I’m trying to chase down the common denominator.

50. Mr.N  |  April 1st, 2008 at 9:14 am

excellent plugin ..
i’ll use it in my wordpress 2.5

51. solodelibros  |  April 1st, 2008 at 5:57 pm

Hi:

I upgraded your excellent plugin in order to use it with the new Wordpress 2.5
I see that Similar Posts isn’t using the Custom Fields option, and I want to know if it is possible yet to include my own words as I did with the older version.

Thanks for your help.

52. Rob  |  April 1st, 2008 at 6:31 pm

solodelibros: Sorry but that ability has been dropped. Instead you can use WordPress’s own tagging to influence the way posts register as similar.

53. Matt K  |  April 3rd, 2008 at 7:08 am

I’ve been running into this seemingly recurring problem:

Fatal error: Cannot redeclare similar_posts() (previously declared in /home/content/m/a/t/mattkastner/html/blog/wp-content/plugins/similar-posts/similar-posts.php:33) in /home/content/m/a/t/mattkastner/html/blog/wp-content/plugins/similar-posts/similar-posts.php on line 33

I’ve done the reinstall and the Post-Plugin Library is already installed. No similar posts sql entry has been made. I was going to try to manually enter the SQL query, but I can’t find the specific instructions for that.

54. Rob  |  April 3rd, 2008 at 10:34 am

Matt K: This infuriating error happens on a minority of sites and I have not yet tracked down the cause. Can you do a complete uninstall (from the settings screen if you can get there) before reinstalling. I’d even go so far as to delete the files before reinstalling. This has worked for some of the afflicted users.

The FAQ (above) has the SQL to create the needed table manually. I’d be glad to hear what works!

55. Simon  |  April 3rd, 2008 at 1:43 pm

Fatal error: Call to undefined function: suppress_errors() in /usr/www/users/investe/altx/reports/wescoal/wp-content/plugins/similar-posts/similar-posts-admin.php on line 405

Plse cud u offer some advice?

56. Matt K  |  April 3rd, 2008 at 5:53 pm

Thanks for the quick response Rob. Unfortunately I have already tried the technique you mentioned many times. My site is hosted on GoDaddy (I had to do a little workaround to install Wordpress at all) so I am wondering if it might have something to do with that.

As far as the SQL you mentioned in the FAQ, I can’t find which entry you are referring to. I would assume it would be in the first question, but I don’t see it. I’m pretty decent at muddling my way through this stuff, but I must admit that I am pretty fresh to SQL. Thanks again.

57. Rob  |  April 3rd, 2008 at 6:09 pm

Simon: the latest posted version should fix that issue.

58. Rob  |  April 3rd, 2008 at 6:11 pm

Matt K: I’ve just uploaded a newer version that might make a difference.

The sql, by the way, is in the second FAQ entry.

59. Matt K  |  April 3rd, 2008 at 7:15 pm

Looks like I won’t be needing to get into the SQL after all. The new version took care of my problem. Its working like a charm. Thanks for everything.

60. simone  |  April 5th, 2008 at 11:28 am

nice plugin, works on my web site

61. Mark Evans  |  April 5th, 2008 at 2:37 pm

Love the plugin - easy to install and configure. One small question: Does the plugin work for posts after installation or can it provide links to previous posts. Right now, I don’t see any Similar Posts on earlier entries.

Mark

62. Rob  |  April 5th, 2008 at 3:18 pm

Mark Evans: It should work for all the posts in your database. Try re-indexing from the Manage | Similar Posts screen.

63. Mark Evans  |  April 5th, 2008 at 6:50 pm

Thanks, Rob. One last question: I now need to insert this:

Where should it go within the index.php or single.php?

Mark

64. Mark Evans  |  April 5th, 2008 at 9:02 pm

Rob,

Figured things out, and installed the plug-in on another blog. Thanks for creating it!

65. Rob in Denver  |  April 5th, 2008 at 9:24 pm

Hi… I also love this plug. I’m getting a similar syntax non-fatal error:

WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1]
SELECT title, content, tags FROM wp_similar_posts WHERE pID= LIMIT 1

I’ve tried many of the troubleshooting tips you’ve given and I still get the error. Also, you mentioned to another commenter to submit a bug ticket from the Settings page. The only settings page I get is the General Settings page (but I recall a page that allowed additional customization).

Halp!

Thanks in advance.

66. Rob  |  April 5th, 2008 at 9:52 pm

Rob in Denver: I’ve found and fixed the bug and it’ll be in the next beta. In the meantime if you want to change the code yourself look in similar-posts.php for the function terms_to_match(…). Add the following line as the first line of the function, even before the globals statement :

        if (!$ID) return array('', '', '');


That should do it.

67. Ben McCann  |  April 6th, 2008 at 12:26 am

Hi,
I love the idea of this plugin, but am having some trouble getting it to work. I have a development site up at lumidant.com/pinknews and every single story shows the same related posts. Any ideas on what my be causing this?
I tried to process the posts to see if that made a difference, but I’m not sure whether it worked. I don’t see anything stored in the database, but am not quite sure where to look. Another comment mentioned wp_similar_posts and that table does not exist.

Thanks,
Ben

68. Rob  |  April 6th, 2008 at 1:13 am

Ben McCann: First, try deactivating and then reactivating. It should create ‘wp_similar_posts’ table (or with whatever prefix you use).

If it doesn’t create the table you can create it manually (try the first or second FAQ entry above).

69. Rob in Denver  |  April 6th, 2008 at 3:34 am

@Rob: Thanks for the bug fix. Attempted, but now I get the mysterious previously declared fatal error. Tried deactivating then deleting then reinstalling to no avail.

But what happened might lend some insight to the aforementioned fatal error.

There’re two places in the plug in where terms_to_match(…) appears:

1. At about line 185. I put the code snippet here and my original non-fatal syntax error still popped up.
2. At about line 78. I dropped the snippet in here… and that’s when the fatal error starts.

70. Rob  |  April 6th, 2008 at 10:34 am

Rob in Denver: Just insert the snippet in the function and not at ~78.

It should look like:


function terms_to_match($ID, $num_terms = 20) {
        if (!$ID) return array('', '', '');
        global $wpdb, $table_prefix;
        ...

Please let me know if that fixes the problem or not.

71. Jinge  |  April 6th, 2008 at 11:31 am

I want the output in every post, not in a widget. How to do that?

72. Jinge  |  April 6th, 2008 at 11:33 am

I want the output in every blog post, not in a widget. How to du that?

73. Rob  |  April 6th, 2008 at 3:10 pm

Jinge: You need to insert the call to similar_posts() somewhere in your theme files. Where that should be depends on the theme you are using and where you want the similar posts list to appear. But, for example, let say you wanted the list directly after the post content on pages that are showing single posts… your theme probably has a file single.php. Open it for editing and you’ll probably see somewhere in the middle the line:

<?php the_content();?>

You could then insert after that line the line:

<?php similar_posts(); ?>

If that isn’t quite where you want it, play around until you have the right place. You might have to tune your style sheet to get the exact look you want.

74. Rob in Denver  |  April 6th, 2008 at 4:58 pm

@Rob… that did it. I just had the snippet in the correct function., just in the wrong line.

Thanks!

75. Yvonne  |  April 7th, 2008 at 8:12 am

Hi Rob, I also got this error when upgrading similar_posts.

Fatal error: Cannot redeclare similar_posts() (previously declared in blah/public/wp-content/plugins/similar-posts/similar-posts.php:33) in blah/public/wp-content/plugins/similar-posts/similar-posts.php on line 33

Here’s my setup: I have 6 active Wordpress blogs on the same server. 5 of them share one database. The problem occurred on the 6th blog (url above), which shares a database with an inactive Wordpress blog. The active blogs are all running WP 2.5. The inactive blog is still on 2.3 or something like that.

I used the upgrade automatically feature to upgrade Similar Posts. It went off without a hitch on the first 5 blogs. On the sixth blog, I got the error when it tried to re-activate. It may be worth mentioning that this is the only blog I didn’t select “Use SSL” when setting up the FTP connection.

The error persisted, no matter how many times I de-activated/deleted the plugin and directory. De-activating/deleting post-plugin-library didn’t help.

What finally made the error go away was removing the plugin via Settings, and then re-activating.

Please e-mail me if you want more details about my setup. Though I’m not sure the setup matters that much — maybe it’s something in the similar_posts settings themselves that’s causing the problem, given that the problem gets fixed if you wipe them…

76. Rob  |  April 7th, 2008 at 8:55 am

Yvonne: I’ve sent you an email following up. Thanks for the detail.

77. CWF Game Cast  |  April 7th, 2008 at 10:07 pm

Rob: You should be aware of http://wordpress.org/support/topic/160383.

I’ve posted in that, as arickrol, for a major problem I’m experiencing with custom fields. Your plugin, Similar Posts, is having problems too. It seems to be a couple hundred, no exagerration, custom fields that have duplicates. Others have the same problem with WP 2.5 but don’t know if they use your plugin.

It has caused me to abandon your plugin so I can try to keep using WP 2.5 (the only way to fix my tags show as numbers issue). I’ve contacted other plugin authors that this deals with. Hopefully everyone can find solutions for their own plugins.

Next stop for me is the podPress people to tell them about the issue too.

78. Rob  |  April 8th, 2008 at 12:05 am

CWF: I’m not sure what you mean by custom fields that have duplicates? Similar Posts 2.5 no longer uses uses custom fields to store data. The only use it makes is to allow the {custom} tag to access a chosen custom field.

Can you describe exactly what is happening?

79. CWF Game Cast  |  April 8th, 2008 at 12:49 am

I deleted all the Similar Posts custom fields to defray the error. But, I had a few hundred custom fields (when making a new post they show at the bottom) and each one listed a bunch of words.

I believe they were words used to find similar posts on the blog. But, many of the entries consisted of saying a single word repeatedly. For example, one said “gaming gaming gaming gaming gaming wargaming wargaming wargaming wargaming war war war war cwf cwf cwf cwf” and etc.

I only received the errors from Firefox, and Safari, when I upgraded to WP 2.5 RC1 and it became much worse when I upgraded to WP 2.5. It is a known bug in WP. But, it seems it only happens with certain plugins. I don’t know the complete list and unfortunately don’t have more information.

80. Rob  |  April 8th, 2008 at 12:59 am

CWF: What you describe is not in itself an error. The OLD versions of Similar Posts stored keywords in a custom field called ’similarterms’ and — because of the way the MySQL full text search works — allowed for the varying frequency of keywords by repeating them.

What is strange is that those fields persist after installing Similar Posts 2.5. The installation routine should have deleted all of them. If you want to do it manually the sql is:

DELETE FROM `wp_postmeta` WHERE meta_key = 'similarterms'

You might have to change the table prefix.

81. CWF Game Cast  |  April 8th, 2008 at 1:01 am

The error is the one given by Firefox. But, the odd thing is not that terms are repeated inside each custom field but that there is a repetition of custom fields.

When one of them lists “war” repeatedly there is another custom field in the list that also lists “war” repeatedly. Somehow they got duplicated.

82. Rob  |  April 8th, 2008 at 1:09 am

CWF: If you are/were using Similar Posts v2.5 there should be no such custom fields and the plugin has no code to do anything with custom fields apart from the one installation routine to delete them.

If you get rid of the lot of them and do a clean install of Similar Posts I’d be gobsmacked if they came back…

83. Chris Masse  |  April 10th, 2008 at 12:15 am

Hello,
Thanks for this great plugin.
There is little problem that you should be aware of. Please, do read what another plugin author said here:
See comments #299
planetozh.com/blog/my-projects/wordpress-admin-menu-drop-down-css/

84. Rob  |  April 10th, 2008 at 12:53 am

Chris: I’m aware of the potential conflict with plugins which replace the admin menus. Their usual technique is to make the original submenu invisible with display: none. That’s why my plugin uses inline styles to reset display. Ozh’s replacement menu uses a different technique: he uses jQuery to actually remove the html of the submenu. Since there is only supposed to be one id of submenu only the first submenu gets overwritten. At least on the systems and browsers I have available.

I have posted about the technique I use for the subpages including, in the last paragraphs, the hazards of ’stealing’ the submenu id.

Can you tell me what system and browser you are having problems with so I can do a workaround?

85. Chris Masse  |  April 10th, 2008 at 2:27 pm

Hi,
Thanks for your reply.
1. I don’t use “Admin Drop Down Menu” anymore. I now use both “WordPress Admin Bar” and “Lighter Admin Drop Menus”. And they work fine with “Similar Posts”.
2. That said, tell me what I should do to help you.
3. I use FireFox 2.0.0.3.
I use Windows ME.
I use WP 2.5.
My plugins:
midasoracle.org/about/software/
(Since last time, I have just dumped “Bad Behavior” for “Spam Free”.)
Regards,
Chris Masse

86. Rob  |  April 10th, 2008 at 9:31 pm

Chris Masse: Well, the only thing that stands out from your response is Win ME… but I doubt that is anything to do with it.

I like the way that the current subpages adapt to the style of the admin interface — stealing the submenu id makes that so easy. There is a javascript way of manipulating style sheets to copy styles but it doesn’t have complete browser coverage. The final fall back would be to forget the chameleon-styling and just inject some nondescript CSS…

Or I could try and convince Ozh to hide the old submenu a different way.

87. Angus  |  April 11th, 2008 at 1:25 am

Help!! Upgraded to 2.5b16 this morning and now my blog is screwed up. I’m using WordPress 2.5

After I upgraded to 2.5b16:

1) it showed 500 error so I deactive it and reactive it then it worked for a while. Then it was working again so I deactive with wp-cache plug-in and it worked again.

2) Now my footer is gone. I didn’t touch anything since (1) in the morning. It was still there in the afternoon but it’s all gone now.

3) Now my some of my right hand side widgets are gone. Can’t add them back at all.

Please Help!!!!

88. zag  |  April 11th, 2008 at 3:27 am

I get a the typical:
Internet Explorer cannot display the webpage

When clicking on Recreate Index

Wordpress 2.5
Similar Post 2.5b16

If I hit f5 or refresh it gets back to the Options page for Similar Posts. Anyone?

89. Rob  |  April 11th, 2008 at 8:08 am

Angus: I’ve responded by email asking some debugging questions. Thanks for your help.

90. Rob  |  April 11th, 2008 at 8:18 am

zag: Can you send me a bug report via the Options page for Similar Posts? That will give me some extra debugging information. Can you tell me the version of IE too?

Meanwhile… do you have the latest version of the Post-Plugin Library installed? Have you tried uninstalling and reinstalling?

Please keep me informed so we can fix this.

91. Dominik Koza  |  April 11th, 2008 at 12:59 pm

Wordpres 2.5 and everything works just fine :) thx.

92. zag  |  April 11th, 2008 at 11:55 pm

I’ve upgraded to latest version, still same problem, is there any way to force the ReIndexing via command line in a shell console instead of wordress control panel.?

Regards nice work.

93. zag  |  April 11th, 2008 at 11:56 pm

.

94. zag  |  April 12th, 2008 at 12:33 am

just found out, not only does not reacreate index, it deletes any entrie on table wp_similar_posts. :(

95. zag  |  April 12th, 2008 at 1:58 am

foudn the problem, solution, I raised the memory_limit on php.ini because I have to many records on wp-post,

tahnk you

96. Charles R  |  April 12th, 2008 at 6:00 am

I was wondering how easy it is to change the font color of the generated links(Similar Posts)?

Thanks

97. Rob  |  April 12th, 2008 at 8:13 am

zag: Good morning! A lot went on while I was sleeping! I’m glad you found the issue and the solution. Can you tell me what the initial memory limit was and what limit made the error go away? Oh and how many posts does your blog have?

Thanks!

98. Rob  |  April 12th, 2008 at 8:17 am

Charles R: It is very easy… You just need to apply some CSS styling. If the default markup is specific enough you can just add to your theme’s stylesheet. If not you can apply a class in the plugins output template, e.g., to the the prefix:
<ul class="posts-list">

99. Vortrack  |  April 12th, 2008 at 5:53 pm

I’m using the default setting but I can’t see ANYTHING that related to my post though they are the same.

100. 2g  |  April 12th, 2008 at 8:40 pm

I have a “Post-Plugin Library missing” error. How can I fix it?

Thanks

101. Rob  |  April 12th, 2008 at 10:16 pm

2g: Just download the library and install.

102. [/root.]  |  April 13th, 2008 at 3:00 am

I’m using this template

{custom:thumbnail-small} {link}

How do I check if the custom field is filled or not? If there is not value in the custom field then it makes an unnecessary space before {link}. Thanks.

103. Rob  |  April 13th, 2008 at 8:08 am

[/root]: Probably the easiest way is to bypass {custom} and use another {php} tag! Try:
{php:$thumb=get_post_meta($result->ID, 'thumbnail-small', true);if ($thumb)echo $thumb.' ';}

104. David  |  April 14th, 2008 at 4:44 am

Upgraded to 2.5b20 from 2.3

WP 2.5

“None Found”

Worked perfect before with 2000+ articles

Tried evrything

In the DB (MySQL 5.+) after config plugin no DB tables are populated within anything.

Went back to 2.3…same problem persists.

105. Rob  |  April 14th, 2008 at 11:30 am

David: A number of questions… did you download the Post-Plugin Library which 2.5 needs? Did you use the Manage page to index your posts? Did you get rid of the old version’s file before upgrading?

Those are the most obvious causes of Similar Posts not showing any posts.

Please get back to me and we’ll get this sorted out. Similar Posts 2.5 has a bug report screen under the settings menu which might provide some useful clues.

106. rufus  |  April 15th, 2008 at 12:22 am

awesome plugin, everything is working fine for me, except today i activated the {views} for the similar posts and its only displaying ARRAY. Post views work fine on my sidebar with another plugin. im using wp 2.5, any advice on why it displays array instead of a number?

107. Rob  |  April 15th, 2008 at 10:28 am

rufus: The {postviews} output template tag relies on you having a plugin installed to do the post view counting. It works with several of the best known such plugins but not all. Which one are you using?

However, if Similar Posts can’t find a plugin to work with it should return zero, not ARRAY, so maybe there is a bug in my code. Let me know which post view plugin you are using and I’ll look into it.

108. rufus  |  April 16th, 2008 at 6:28 am

im using WP-PostViews, you can find it here http://lesterchan.net/wordpress/downloads/

109. Nathan Cain  |  April 16th, 2008 at 2:58 pm

When I click on any of the option tabs in similar posts OR recent posts, I get an error that says “Cannot Load Recent.” OR “Cannot Load Similar”

110. Rob  |  April 16th, 2008 at 3:08 pm

Nathan Cain: Is this a new installation of these plugins? If it was an update make sure you removed the old plugin folders. Have you downloaded and installed the Post-Plugin Library whcih the plugins now require?

Also try simply deactivating/reactivating the plugins. Remember to go to the Manage >> Similar Posts page to index your blog.

111. David  |  April 16th, 2008 at 3:11 pm

Further to #104/#105

Entirely my fault. Duh.

I went to Settings > Similar Posts and set all the options but not clearly realizing I also had to go to Manage > Similar posts.

May i suggest placing all options within one UI location in future?

112. Nathan Cain  |  April 16th, 2008 at 3:21 pm

Rob - This is a new installation. I downloaded and activated the post-plugin library first. I reindexed under manage>similar posts. I deactivated and reactivated these plugins and I am still getting the errors.

113. Rob  |  April 16th, 2008 at 3:22 pm

David: I’m glad you solved the problem! I was worried by your initial description–I thought we had obliterated your blog!

The indexing thing is a chore. Originally, I had the installation routine do a basic index but it failed on some odd systems with very weird and uninformative error messages so now I leave it to the user to do a manual index. As you found out that’s unsatisfactory for several reasons.

114. Rob  |  April 16th, 2008 at 4:40 pm

Nathan: I am puzzled. Can you tell me anything about your system? Apache? Versions of PHP, MySQL, etc. I have had one previous report of the subpages not working with a certain variety of IIS.

Also are you using wp-cache or an admin drop menu plugin?

Can you check to see if a table has been created called ‘wp_similar_posts’ and if that table has been filled with as many rows as the wp_posts table?

I hope we can resolve this speedily.

115. gero  |  April 16th, 2008 at 11:16 pm

Hello Rob,

it’s not a bug, but a thing that should be changed in the next version:

If you include the Similar Posts in the rss-feed, there is no option to set (or translate) the string before the tag. It says hard-coded “Similar Posts:”

It would be great, to have the possibility to change this string like in the other options-page.

Greetings
gero

116. Rob  |  April 17th, 2008 at 4:47 pm

gero: Which version are you using? In v2.5 when you choose to have similar posts’ output to your feeds a new setting menu is created which lets you tailor the output to feed as much as you want, including changing the string before the tag.

117. Mara Mei  |  April 18th, 2008 at 5:12 am

This plugin work perfectly at my blog. Thank you.

118. rufus  |  April 18th, 2008 at 6:20 am

Rob were you ever able to get the postviews counter on your plugin to work with the wp-postviews plugins i linked above? the Array message can be seen on my blog. wp-postviews can be found here http://lesterchan.net/wordpress/downloads/ thanks for all your hard work.

119. Rob  |  April 18th, 2008 at 9:41 am

rufus: Sorry an email to you must have gone astray. It looks like Lester updated his plugin so the code had to be changed for the next version. In the meantime you can edit post-plugin-library/output_tags.php if you wish and make the patch.

Round about line 380 you’ll find the code to handle postviews, update it to:

        else if (function_exists('the_views')) {
                $count = get_post_custom($result->ID);
                $count = intval($count['views'][0]);
        }       

See if that does any good.

120. gero  |  April 18th, 2008 at 10:40 am

Oh, sorry,
yes, perfect! There are feed option. I just haven’t noticed, that they appear not in the similar feeds option, but in extra settings.
Everything is perfect :-)

121. john  |  April 19th, 2008 at 2:45 am

I placed the recent_posts on the sidebar and all works well. What would I need to do to get the same list to show up on my homepage which is outside of wordpress.
So say public_html/wordpress –> wordpress blog
I want to access it from public_html/index.php

122. Rob  |  April 19th, 2008 at 10:01 am

john: I’m not sure! You will have to ‘include’ the plugin and at least some of the WordPress files — which I am not sure. Maybe the codex has something on the subject?

123. Jenny  |  April 19th, 2008 at 1:20 pm

The plugin is working, but each post is only picking up that same post as a related site.

I’m not sure how to set it up really whithi the settings part. I have recreated my index.

124. Rob  |  April 19th, 2008 at 3:52 pm

Jenny: Can you make a bug report from the Similar Posts setting screen … that might give me a clue as to what is going on.

125. Crystal  |  April 21st, 2008 at 9:35 pm

I just upgarded to 2.5b22. I followed the steps as stated in the instructions and now no post will show up. It says ‘None Found’ I tried deactivating and reactivating and I still get the same thing. It worked fine before I upgrading to the new version. I went though all the setting, everything is fine. What did I do wrong?

126. Rob  |  April 21st, 2008 at 10:30 pm

Crystal: Have you indexed the posts? Always worth asking! Perhaps you could submit a bug report from the settings page which will give me some extra information. Could you also tell me what version you upgraded from?

127. Crystal  |  April 21st, 2008 at 10:43 pm

I did index. Honestly I can’t remember what version I had before I upgraded. It was a more recent one, I know that, as I usually check my plugins a few times a month and upgrade them when needed. I just submitted a bug report.

Crystal

128. Rob  |  April 22nd, 2008 at 12:08 am

Crystal: I think I know what the problem is. You have the plugin set to match both categories and tags and that is a very strict condition. Try unsetting those options and see if the related posts come back.

This is a change of behaviour from previous versions where — somewhat illogically — if such matching yielded no hits the plugin reverted to just ignoring the tags and/or categories.

129. Crystal  |  April 22nd, 2008 at 1:04 am

I unset the options you said and it works now. I had those options set-up before and it worked. Oh well….as long as it’s back up and running I’m happy. I’ve used this plugin for all my blogs, I love it. :)

Thanks for your fast response helping me out.

130. Max  |  April 22nd, 2008 at 10:02 am

I’m using the plugin on wordpressMU V 1.2.5 I get the same output on every page. I’m not sure where to go form here. Thanks in advance for any help you might be able to provide.

131. Rob  |  April 22nd, 2008 at 12:18 pm

Max: I must confess I have been wanting to explore how to make sure my plugins work properly with WPMU for some time but I have never gotten to it.

Do you know of any differences I should take into account? Any, perhaps you could make a bug report from the options/settings page as that will at least give me some information that might be useful.

132. Paul  |  April 22nd, 2008 at 2:23 pm

Just upgraded post-plugin-library to the latest, whenever I post or edit a post, I receive this error.
Warning: exec(): Unable to fork [tasklist /FI "PID eq 10152" /FO LIST] in ….\wp-content\plugins\post-plugin-library\common_functions.php on line 441

I downgraded to an earlier version, and that resolved this problem.
btw. great plugins.

133. Rob  |  April 22nd, 2008 at 3:24 pm

Paul: That’s due to a misplaced bit of code. I’ll have it fixed shortly. Thanks for the heads up.

134. Max  |  April 23rd, 2008 at 1:01 am

Ok, I’ve just tested a couple of things and found that the problem is not caused by wordpressMU it’s actaully theme related. I’ve been testing with an old theme in MU and it works like a charm.

Now I am not sure how to fix the problem so I have had to disable the plugin again. Why would a theme cause the pugin to pull the same posts on - the theme is quite popular http://www.copyblogger.com/the-copyblogger-theme-for-wordpress/ - try it out and I think you will be able to see the problem straight up.

135. Rob  |  April 23rd, 2008 at 10:51 am

Max: It could happen if the them has multiple ‘loops’. Similar Posts has to find out somehow which post is the current one so as to compare it to others for similarity. It gets the current post’s ID by looking at the $post variable which is set in the WordPress loop. If theme or plugin or widget runs a second wp-query/loop without restoring its context Similar Posts will have the wrong ID play with. This problem can occur easily with widgets since some of the built-in widgets don’t properly clean up after themselves (though the code has attempted to since 2.5).

There is no need for themes, plugins etc. to make this mess as Ronald Huereca explains.

136. Jenny  |  April 23rd, 2008 at 11:01 am

I changed themes and before that the plugin worked fine. Now it is suddenly appearing in a widget, not that I mind.

137. Paul  |  April 23rd, 2008 at 11:27 pm

Rob: Thank you for your great plugins. I just upgraded to v23 of post-plugin-library and all is well. Thank you, again.

138. Cho Kwan Hee  |  April 24th, 2008 at 2:50 am

I finisihed to install in my blog just before. And it works well.

It is what I’ve been looking for.

Thanks!

139. Gareth Stack  |  May 1st, 2008 at 7:29 pm

I’ve installed Posts Plugin Library on Wordpress 2.3.3. But when I try to install similar posts I get the following error

Warning: require_once(/home/.fenne/dbspin/analoguemagazine.com/wp-content/plugins/similar-posts/languages/en/stemmer.php) [function.require-once]: failed to open stream: No such file or directory in /home/.fenne/dbspin/analoguemagazine.com/wp-content/plugins/similar-posts/similar-posts.php on line 551

Fatal error: require_once() [function.require]: Failed opening required '/home/.fenne/dbspin/analoguemagazine.com/wp-content/plugins/similar-posts/languages/en/stemmer.php' (include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in /home/.fenne/dbspin/analoguemagazine.com/wp-content/plugins/similar-posts/similar-posts.php on line 551

140. Rob  |  May 2nd, 2008 at 10:58 am

Gareth Stack: It seems likely that you haven’t uploaded the languages folder inside the similar-posts folder.

141. Sue  |  May 3rd, 2008 at 2:44 am

Hi Rob,
I am using the thumbnail option with similar posts and love the result, with one glitch - for youtube posts, there is no thumbnail. Is there a workaround for this?
Thanks!
sue

142. Rob  |  May 3rd, 2008 at 10:31 am

Sue: I’m afraid not since youtube videos are not images. There may be a way extend the {image} output tag without too much trouble or overhead … I’ll look into it.

143. Rob  |  May 3rd, 2008 at 11:00 am

Sue: There seem to be so many ways to embed videos — many of them non-standard — that I think you are out of luck for the near future.

144. djvibe  |  May 8th, 2008 at 10:36 am

Any language for chinese? where can I get this..

145. Naveed Taj Ghouri  |  May 8th, 2008 at 1:09 pm

I have tried everything, DB table is there, i uploaded library plugin first then this one, activated them, put string in my post but it is causing a Fatal error, although its activated and configuring well.. wat to do?

146. rosa de paz  |  May 8th, 2008 at 11:44 pm

Please! i do everithing that u said but i only find NONE FOUND,
I go to the edit plugins, and chek the code that you put… but it don{t work… can you please tell me what happend??
i have the wordpress 2.5

147. gero  |  May 9th, 2008 at 6:55 am

Hello,

I’m using WP 2.5 and the newest version 2.5b26 of the plugin.

Since - I can’t say the version exactly - I’ve noticed, that the results of the similar posts are not as good as they used to be, although I have not changed the settings.

I also noticed a strange thing: if I recreate the index with “manage the index” the results under some postings are quite strange. I know that there are postings, which are quite more similar, but they do not appear.

If I than open this posting and just save it again (without changing anything) the similar posts shown under it are much better now.

How can it be, that the results are different?

Greetings

148. nonhocapito  |  May 9th, 2008 at 10:03 am

This plugin is fantastic.

Only problem… because I have another plugin that modifies my feeds, every time I upgrade your plugin I have to manually edit line 560 (or near that line) from this

if ($options['feed_active'] === 'true') add_filter('the_content', 'similar_posts_for_feed');

to this

if ($options['feed_active'] === 'true') add_filter('the_content', 'similar_posts_for_feed', 99);

because the other filter must come first (long story).

well, it would be awesome to have this in the options! :)

149. Tony  |  May 9th, 2008 at 6:19 pm

I was wondering… how could I display similar posts on my 404 page? When Google sends people to a 404 page, I would like the 404 page to display posts similar to the one that was being searched for through Google.

150. Rob  |  May 10th, 2008 at 10:23 am

djvibe: There are no stopword/stemmer files for Chinese for a couple of reasons. First, I know no Chinese and don’t even know whether the concept of stopwords etc. is relevant. Second, I do know that the MySQL full-text index the plugin uses has trouble with the Chinese, Japanese, and Korean languages because they don’t use spaces to separate the text into words.

If you can shed any light on these issues I would be very happy to add support for the CJK languages.

151. Rob  |  May 10th, 2008 at 10:32 am

Naveed Taj Ghouri: Thank you for your comment. I have just visited your site and I think I might know the problem: the text in your posts seems to be presented as images. Is that correct? If it is then Similar Posts would have no text to index. It should however be able to give matches based on your tags and titles and if it is giving a fatal error I need to fix that.

Can you submit a bug report from the Similar Posts settings page? It will give me a little extra information that might help. Thank you.

152. Rob  |  May 10th, 2008 at 10:35 am

rosa de paz: Please make a bug report from the plugin’s settings page and it will give me something more to go on. Thanks.

153. Rob  |  May 10th, 2008 at 10:37 am

gero: You are right! I investigated and found a bug in the bulk indexing of tags that isn’t present in the indexing of individual posts. When you save a post it gets reindexed and the matches suddenly get better. I have fixed the bug and will be posting an update shortly. Thanks for finding the problem!

154. Rob  |  May 10th, 2008 at 10:41 am

nonhocapito: I can understand how irritating that must be. It feels a bit bit technical to have as an ordinary option. Would it satisfy you to have it as a ‘hidden’ option you can get at from the global options.php?

155. Rob  |  May 10th, 2008 at 10:52 am

Tony: As it stands, Similar Posts needs to have a post to find similarities to, so it can’t be done. Since searches tend to be on short phrases or a few keywords my first thought is that similarity might not work very well — a simple site search might be better.

What do you think? If the idea has some merit I’d be glad to look into implementing it.

156. Jeremy  |  May 10th, 2008 at 6:12 pm

Rob, thanks for the great plugin. I am using it to show 5 titles of similar posts on my single post page. Is there anyway to have the output include rel="nofollow" so that the page rank from the post is returned only to the home page?

Thanks,
Jeremy

157. Rob  |  May 10th, 2008 at 8:52 pm

Jeremy: You just have to build the link yourself, i.e., instead of
<li>{link}</li>

use

<li><a href="{url}" rel="nofollow">{title}</a></li>

You can also include a title attribute if you wish.

158. gero  |  May 11th, 2008 at 6:01 pm

Hello Rob,
just installed version 2.5b27 and rebuild the index.
Now the similar posts really look great again! Thanks for the bugfix.

My advice is, that everybody should rebuild the index (options -> manage the index), to get better results.

Greetings
gero

159. Rob  |  May 11th, 2008 at 6:37 pm

gero: I spotted another bug — if you use the extended character option — and uploaded v2.5b28 to fix it.

The new version also contains an experiment in handling Chinese, Korean, and Japanese text.

160. Mark @ News Corpse  |  May 11th, 2008 at 10:56 pm

Hi Rob,

I just upgraded both WP and Similar Posts and I have 2 questions.

1) I have enabled the sort order on date-descending, but the output does not display sorted that way.

2) I understand that the similarterms custom field is now in a table. I used to edit that field frequently to improve results. Is there no way to do that now? Could an edit feature be added? Tagging is not really a comparable replacement for editing terms. For one thing, you can’t remove terms that way.

Thanks for the great plugin. I hope you can help with these issues.

161. Tony  |  May 12th, 2008 at 6:16 am

Rob, I can get the string.

$uri = $_SERVER['REQUEST_URI'];
$uri = rtrim($uri, '/');
$new_string = str_replace("/", " ", $uri );
$final_string = str_replace("-", " ", $new_string);

… and I can pass the string to a Wordpress search, albeit, it is not automatic.

<form method="get" id="searchform" action="http://mysite.us/">
<div>
<input type="text" value="<? echo $final_string; ?>" name="s" id="s" >
<input type="submit" id="searchsubmit" value="Search" >
</div>
</form>

However, I would like to pass along the string to the similar posts plugin to return “Posts that you might have been looking for ,,,” on the 404 page itself.

What do you think?

162. gero  |  May 12th, 2008 at 7:09 am

Hello Rob,
my blog is in german (with umlauts) but I never used the extended character option. I never noticed any big differences in the results. I switched it on now and yes, I must say that after reindexing, the results got again a bit better.
I love your plugin very much. It is quite amazing, how it finds similar posts without making any manual connections. Great!

gero

163. Mark @ News Corpse  |  May 12th, 2008 at 7:21 am

Hi again Rob.

I figured out the sort problem on my own (I added ‘raw’ to the date format), but I would still like to know if anything can be done about editing the terms.

I was able to significantly improve the results by manipulating the similarterms in the custom field. I already miss not being able to do that anymore.

(I mistakenly posted this in comments on a different post on your site. Sorry for the repeat)

164. Rob  |  May 12th, 2008 at 10:21 am

Tony: You’d have to hack the function sp_terms_to_match. Right now it takes the ID of the current post and gathers terms to put into the search. You could instead inject your own terms.

I’ll be interested to see what you come up with!

165. Rob  |  May 12th, 2008 at 10:22 am

gero: Thanks!

166. Rob  |  May 12th, 2008 at 10:28 am

Mark @ News Corpse: I missed the first comment somehow. I’m glad you figured it out.

There’s now way to edit the terms now as they are generated on the fly. Does the use of tags not help?

167. Rob  |  May 12th, 2008 at 10:45 am

Mark @ News Corpse: Sorry Mark. I just found your original comment in spam and brought it back to life. Please discount my mention of tagging above!

The table you mention doesn’t exactly store the ’similar terms’ — rather it stores a pre-processed representation of post content, title, and tags. When it comes to query time, that representation for the current post is further processed to generate the ’similar terms’ which are then compared with the representations for every other post. Editing the table is possible but you would be editing both the search terms (if they were judged significant) and the text to be searched.

If you want to experiment load up phpMyAdmin (the wp plugin is very helpful) and see if editing does what you want it to. I’d be interested to know the answer.

168. Mark @ News Corpse  |  May 12th, 2008 at 5:06 pm

Thanks for your response (and for finding my lost question).

If I understand you, it seems the whole method of operation has changed from previous versions. But let me give you some examples of why access to search terms was useful for me.

1) There were often multiple duplications of words in similarterms. I sometimes saw a word repeated 7 or 8 times so I would remove some of the duplicates.

2) The plugin would sometimes pick up words that were not relevant. For instance, in a post about the cost of groceries, the sentence: “My sister paid $3.00 for a quart of milk,” might index milk, quart, paid, and sister. But “sister” isn’t useful for similarity in this context. Plus it could match it with another post about a nun. So I would remove “sister” and get better matches.

3) I could add terms that might not even be in the post so that it would use them to match other posts that I knew also had those terms. I wouldn’t want to clutter up my tags with these sort of words.

I know similarity matching is part science, part magic, and nothing will be perfect. You’ve done a damn nice job of it. One idea I had is to have the plugin produce a display of what terms it’s indexing. Then allow a custom field for the user to input additional search terms and terms to exclude (preceded by a minus sign). Then the user could fiddle with the results without having to leave the post to edit the DB.

Does any of this make sense?

169. Mark @ News Corpse  |  May 12th, 2008 at 5:13 pm

One more thing. In the previous version I noticed that the plugin would set the search terms when WordPress autosaved the post - even if I was not finished writing it. So, many terms didn’t get into the index unless I added them later. However, if I wrote the whole post without entering a title, this would not happen because it didn’t get autosaved until the title was entered. I guess that’s a WP thing, but it definitely affected the plugin’s choice of search terms.

Does that play into the current version of Similar Posts in any way?

170. Joe  |  May 12th, 2008 at 5:24 pm

Great Pluggin! Thanks a bunch!

171. Rob  |  May 12th, 2008 at 10:54 pm

Mark: Last point first: yes WordPress brought in autosave after Similar Posts had hooked into the save function and since I was trying to preserve the custom field once it was saved it got messy.

1) The duplications were in fact a way of getting MySQL to give extra weight to the most frequent terms

2) and 3) are very valid points but they rely upon a once and for all indexing of the posts and I have tried to shift to a more dynamic model where you can experiment with different approaches to index and term extraction and the relative weights of different factors.

The idea of a separate scheme to add or subtract terms is a possibility I will bear in mind–especially if I can find a way that doesn’t impact performance too much.

172. Mark @ News Corpse  |  May 13th, 2008 at 1:16 am

Thanks. I agree that a dynamic model has some attractive benefits. And overall, a plugin that requires no intervention from the user is the ideal. But I just think that’s fairly impossible and that the ability to fine tune results is useful.

I had another idea: What if words in the post could be tagged so that the plugin would include/exclude them? Something like include this and exclude that

You wouldn’t need a custom field for this and it wouldn’t be any more difficult than using italics. It could even be added to the quicktags.js.

173. Mark @ News Corpse  |  May 13th, 2008 at 1:19 am

Oops. My example didn’t display. It should have said:

Something like include <sp+>this</sp> and exclude <sp-> that</sp>.

I hope this shows up correctly.

174. Sue  |  May 13th, 2008 at 5:14 am

Rob,
2 quick things. The first is, since the update just before this one, Similar posts is including the current post as one that is similar - to itself. In one case tonight, it presented the current post as similar to itself twice in the same post.

The other thing is, I apologize for confusing the thumbnail issue. what I am hoping for is the ability to specify the image for Similar Posts to use if one is provided in the post. This way, the you tube videos and any other posts without images will have a thumbnail.
many thanks,
Sue

175. Rob  |  May 13th, 2008 at 10:14 am

Mark @ News Corpse: That’s a good idea! The only catch is what happens to the added markup if — heaven forbid — you should ever abandon Similar Posts. I’ll give it some more thought. Thanks for being persistent.

176. Rob  |  May 13th, 2008 at 10:15 am

Sue: I’m looking into point one. As for point two: do you mean to supply a fallback image to use if the post lacks one?

177. seat  |  May 14th, 2008 at 8:22 am

Hello Rob,

I have set the relative importance as follows:
content:0 % title:100 % tags:0 %
hoping to get exact match of post titles(which will be names of restaurants in my blog) but it doesn’t seem to work.

I have chosen “Show nothing if no matches” but irrelevant posts are listed like in these two posts:
http://www.potatomato.com/seat/2008/04/28/jean-paul-hvin-2/
http://www.potatomato.com/seat/2008/05/06/chez-inno/

While these two posts have the same titles but no “similar posts” are listed.
http://www.potatomato.com/seat/2007/09/28/la-rochelle-minami-aoyama/
http://www.potatomato.com/seat/2007/09/04/la-rochelle-minami-aoyama-2/

I have set “treat as Chinese, Korean, or Japanese?” to yes.

178. Rob  |  May 14th, 2008 at 11:23 am

seat: Mmm food!

Similarity is judged according to MySQL’s complicated word-based algorithm, so exact matches are always unreliable. Add in the difficulty Japanese presents to MySQL and all bets are off!

The current attempt to work with C/J/K is very much a first try. It treats individual characters as if they were ‘words’ — a real hack. The next version which will appear soon is based on digrams which seems to get good results in the literature on similarity but, while better, is not likely to give you exact matches.

I will be very interested to get feedback from you to make this work better.

179. seat  |  May 14th, 2008 at 12:08 pm

Thank you for the quick response. So getting an exact match is no easy feat… I look forward to the new version. Keep up the good work! :)

180. fred  |  May 14th, 2008 at 8:14 pm

Hey,

Very nice plugin!

I was having issues with it lately though, new posts wouldn’t have any related posts found, and the server logs be filled with database errors from Wordpress.

Apparently you have misplaced a closing parenthesis on line 71 when determining whether there are posts to exclude or not, and when there’s not then $exclude_posts is still set to true, resulting in a query with a ” ID NOT IN ( ) ” which of course gets an SQL error.

// you have this:
$exclude_posts = (trim($options['excmµçVFVE÷÷7G2uÒÓÒrr’“°Ð¢òòv†–ÆR–÷R6†÷VÆB†fRF†—2‡6ÖR2v—F‚F–æ6ÇVFU÷÷7G2’ ТFW†6ÇVFU÷÷7G2Ò‡G&–Ò‚F÷F–öç5²vW†6ÇVFVE÷÷7G2uÒ’ÓÒrr“°Ð

Thanks again for the great work!
-fred

181. fred  |  May 14th, 2008 at 8:16 pm

hmm… things got mesed in in the code block it seems.
Anyways, here it goes again, hopefully it will work this time:
$exclude_posts = (trim($options['excluded_posts'] !== ”));
I think should be this:
$exclude_posts = (trim($options['excluded_posts']) !== ”);

182. Rob  |  May 14th, 2008 at 9:42 pm

fred: You are dead right! Thanks a lot.

Leave a Comment

Required

Required, hidden