A Better Related Posts Plugin

There are many plugins that find related posts for WordPress, and I was happy to use one of them in the past. However, WordPress evolves. One of the biggest change was the addition of custom post types. They are very useful and I use them a lot for my own and for client sites. And this is where every related posts plugin I tested failed: They don't support custom post types.

While reviewing the code of several plugins I decided that the Right Thing would be to write a new plugin from scratch. And that's what I did. Key features:

  • Depends on PHP5 and MySQL5
  • Option to add related posts to the RSS feed
  • You can theme the output as you like
  • Use fulltext indexes for good performance
  • Does caching through post meta, this means zero additional database queries
  • Incremental scoring for sites with many posts
  • Find related posts, pages and custom post types
  • Use different configurations at the same time, useful for different post types
  • Internationalized, OO, hopefully well documented and readable
  • Score relationships by various MySQL relevance scores or term relationships

Use tags, categories or custom taxonomies

The readme.txt contains extensive documentation. It is possible to create completely custom views of related content, including post thumbnails, date, excerpts etc.

Downloads are available at WordPress.org.

Most plugin demos are disabled at the moment. I'll restore them as soon as possible.

Published on Oct. 31, 2010 at 2:08 p.m. by Nicolas and tagged related posts, related content, custom post type, WordPress plugin, custom taxonomy, WordPress. You can follow the discussion with the comment feed for this post.

218 comments

  • avatar
    .:Heather:. wrote this comment on Nov. 2, 2010, 9:15 p.m.
    I've downloaded and activated this plugin but it's not showing up on my pages. Am I missing something??
    Reply to this comment
    • avatar
      .:Heather:. wrote this comment on Nov. 2, 2010, 9:18 p.m.
      Well I figured out how to make it on the post BUT it's showing 8 queries in 0.0966 seconds, current offset 0 after the words Related Content. How do I get rid of that and the numbers after the related post link??
      Reply to this comment
      • avatar
        nicolas wrote this comment on Nov. 3, 2010, 12:37 p.m.
        You can turn this information off on the options page. It is only displayed to logged in admins, not all visitors.
        Reply to this comment
  • avatar
    ubas wrote this comment on Nov. 4, 2010, 8:26 p.m.
    i've activated this plugin on WPMU and i get error : "There is no fulltext index for wp_1_posts.post_content" "There is no fulltext index for wp_1_posts.post_title" Am I missing something?
    Reply to this comment
    • avatar
      nicolas wrote this comment on Nov. 4, 2010, 9:01 p.m.
      Oh, did you perform a network activation of the plugin? I guess that would trigger the error on all blogs but the one you activated the plugin on.
      Reply to this comment
    • avatar
      nicolas wrote this comment on Nov. 4, 2010, 9 p.m.
      Which MySQL version are you running? The fulltext index should be created at plugin activation, and IIRC the plugin checks for the indexes every time you access the options page.
      Reply to this comment
    • avatar
      nicolas wrote this comment on Nov. 4, 2010, 9:25 p.m.
      If you did a network-wide activation please try again with the current trunk version: http://wordpress.org/extend/plugins/better-related/download/ (trunk should appear in a few minutes)
      Reply to this comment
  • avatar
    Ovidiu wrote this comment on Nov. 5, 2010, 11:57 p.m.
    Just getting started with this plugin and I need to know what values the multiplier fields take? is it just 0/1 or up to where? Need a bit more info on this...
    Reply to this comment
    • avatar
      nicolas wrote this comment on Nov. 6, 2010, 12:07 a.m.
      They are simply integers and there's no limit. Actually, I should probably make them floats...
      Reply to this comment
      • avatar
        Ovidiu wrote this comment on Nov. 6, 2010, 12:11 a.m.
        ok, thx. just wondering as by default two fields had 1 the rest had 0... will experiment a bit... I guess everyone has figure out his own values depending on what he uses most, categories/tags/etc..
        Reply to this comment
  • avatar
    Ovidiu wrote this comment on Nov. 6, 2010, 12:14 a.m.
    ok, now totally confused. I read above: The scoring methods... so it seems the multiplier fields are not used at the same time? Where do I select a scoring method?
    Reply to this comment
    • avatar
      nicolas wrote this comment on Nov. 6, 2010, 2:04 a.m.
      Each scoring method has it's own multiplier, that you can set on the options page. Setting it to 0 will disable that scoring method. Use the_related_analyze(); to analyze which scoring methods are relevant for you. Hide that from normal visitors on the frontend though, use current_user_can().
      Reply to this comment
      • avatar
        Ovidiu wrote this comment on Nov. 6, 2010, 2:27 a.m.
        I really don't understand. what do you mean relevant? I think all are relevant I just need to assign them a particular score depending on how goo the results they yield are? So if a particular scoring method gives me good results I raise its score, right? maybe lower or disable those that don't give good results and be happy with the resulting mix? btw. what are keywords? meta-keywords?
        Reply to this comment
  • avatar
    Ovidiu wrote this comment on Nov. 6, 2010, 4:05 a.m.
    I seem to be having some problems with the automatic injection into pages. the pages where I have hte problem, all have some sort of shortcode, either gallery shortcodes or other ones in them... it works for pages without shortcodes though. And I know there is related content because I used he_related_analyze(); to check it out...
    Reply to this comment
    • avatar
      nicolas wrote this comment on Nov. 6, 2010, 3:38 p.m.
      I have never seen this problem. Please disable or delete all plugins and switch to the default theme. The default theme in WordPress 3.0.x is Twenty Ten. After making these changes does the problem still occur? If not, switch the plugins on one by one and tell me which one creates the problem, I'll have a look.
      Reply to this comment
  • avatar
    Patrick wrote this comment on Nov. 8, 2010, 12:40 a.m.
    Hello, I got 2 posts in the same category. On the newer post the older one is under "Related Posts". But on the older posts the newer one doesn't appear. How do I make this work?
    Reply to this comment
    • avatar
      nicolas wrote this comment on Nov. 8, 2010, 2:21 p.m.
      Hi Patrick, you can lower the score necessary to display results or show more related posts. The relevance score varies, depending on which direction the relatedness tests are performed.
      Reply to this comment
      • avatar
        Patrick wrote this comment on Nov. 10, 2010, 8:29 a.m.
        Thanks for your advice. Lowered it to about 35 and it works now. :)
        Reply to this comment
        • avatar
          nicolas wrote this comment on Nov. 10, 2010, 1:16 p.m.
          Ok, great! I'm currently working on a new feature to set related posts manually as well. Hope to release it soon.
          Reply to this comment
  • avatar
    oliver wrote this comment on Nov. 11, 2010, 5:09 a.m.
    hey, I am very glad to have found your plugin. it looks awfully useful, especially given all the fine tuning between post content, title, category and such! – my problem: I have included "" in my sidebar. while the plugin shows "related" posts under the single post, it at the same time says "no related" in the sidebar... ... can you help? thanks!
    Reply to this comment
    • avatar
      oliver wrote this comment on Nov. 11, 2010, 11:56 a.m.
      PS: “” meaning the php-template-tag
      Reply to this comment
      • avatar
        nicolas wrote this comment on Nov. 12, 2010, 12:15 p.m.
        Hi oliver, I assume you meant the_related() ? You can pass the post ID as first parameter in the sidebar, that should work.
        Reply to this comment
        • avatar
          oliver wrote this comment on Nov. 12, 2010, 4:49 p.m.
          thanks for the feedback, Nicolas! – but this hasn´t changed the display. ...at least if you were meaning taking out the »get_the_ID(),« line of the call-function. still I get the "no related" in the sidebar, though results are there with the same code-lines [including the ID call] in the body... [on the sidetrack: still what the parameters of what I put in the sidebar actually do control is the display-behavior of the "automated display in post"-function if that setting is turned on... so there seems to be something going on in the background... :-}] PS: … what actually happens when I take out the ID-line, is that the sidebar display switches to the heading filled-in in the custom-presets section of the plugin (even though automatic display for posts is turned off there)
          Reply to this comment
          • avatar
            Paul wrote this comment on May 23, 2011, 3:20 p.m.
            Hi
            I have the same problem and still no solution
            Reply to this comment
          • avatar
            nicolas wrote this comment on Nov. 12, 2010, 5:14 p.m.
            Please keep in mind that I can't see your code, I don't really know what you are trying to do. It's probably filtered away because you used php tags. http://codex.wordpress.org/Function_Reference/get_the_ID : This tag must be within The Loop.
            Reply to this comment
  • avatar
    Leonardo wrote this comment on Nov. 12, 2010, 9:14 a.m.
    Hello! I tried to install this plugin using WP Admin and through FTP too, but It keeps showing: There is no fulltext index for wp_posts.post_content There is no fulltext index for wp_posts.post_title What can I do to fix it? Thanks!
    Reply to this comment
    • avatar
      nicolas wrote this comment on Nov. 12, 2010, 12:42 p.m.
      Hi, I think this is a bug. I've just released 0.4.3 which should hopefully fix this problem. you need to deactivate the plugin and activate it again.
      Reply to this comment
  • avatar
    Laurent wrote this comment on Nov. 12, 2010, 3:24 p.m.
    This plug-in looks great ! However I've got the same problem than ubas for my blog : http://windows-mobile.fr Could you help me please ? Best regards
    Reply to this comment
    • avatar
      Laurent wrote this comment on Nov. 12, 2010, 3:26 p.m.
      I've installed 0.4.3 (from scratch as I've just discovered your plug-in ;-) ) but I've got the same issue...
      Reply to this comment
    • avatar
      nicolas wrote this comment on Nov. 12, 2010, 3:37 p.m.
      Which MySQL version are you running? It has to be 5 at least. If you are on v5 try to run the command "CREATE FULLTEXT INDEX content_index ON wp_posts (post_content);" in phpmyadmin or another mysql client. Do you get an error, if yes which?
      Reply to this comment
  • avatar
    dave wrote this comment on Nov. 18, 2010, 12:39 p.m.
    excellent plugin. however, how do i stop the current article being the first related post? i don't want users going round an endless loop. my current article always has a score of around 51000, and is always displayed as the first related post. all following articles are between 125 and 50 (my min score setting). i would like to list "other" related pages, and not say "you might like to read the article you're already reading. it's relevelant!" ;) thanks for your help.
    Reply to this comment
    • avatar
      nicolas wrote this comment on Nov. 18, 2010, 12:42 p.m.
      Hmmmm, that's odd. How is the list generated on your site? Do you just use the built-in auto-add feature? This shouldn't be happening.
      Reply to this comment
  • avatar
    Patrick wrote this comment on Nov. 19, 2010, 12:08 a.m.
    Tag to Taxonomy Multiplicator okay, but why not Category to Taxonomy Multi? If I got two posts with the tag "action" then they are linked. Fine. But if I got two posts of the same category (some posts have more than one cat, dont know if thats a problem) then they should also appear. They do not. Only if I go down to 10 % match and then it shows too much stuff.
    Reply to this comment
    • avatar
      nicolas wrote this comment on Nov. 19, 2010, 3:10 p.m.
      Yes, there's room for improvement for the term to term relationship scoring. I plan to work on that for the 0.5 release. It's "Term to taxonomy multiplier" btw, and should probably be called "Term to term multiplier", so it applies to tags, categories and any custom taxonomies. Personally, I don't think that just sharing a category should make a post related automatically, but that's what the Term to tax multiplier is for, you can set it to something higher.
      Reply to this comment
  • avatar
    Thompson wrote this comment on Nov. 25, 2010, 10:19 p.m.
    Could you give an example of your manual inclusion code that defines a specified custom post type and custom taxonomy please? For the life of me I can't figure out how to modify the manual inclusion code to specify the custom post type and custom taxonomy that it should use.
    Reply to this comment
    • avatar
      nicolas wrote this comment on Nov. 27, 2010, 9:21 a.m.
      The section "How to use different configurations at the same time" in the readme is all you need. The plugin will use the custom taxonomy your post type uses anyway. The usetax parameter is only for searches across different taxonomies, I assume you don't need that?
      Reply to this comment
      • avatar
        Thompson wrote this comment on Dec. 7, 2010, 6:55 p.m.
        Thanks Nicolas. I tried the code you mentioned (below) and it works. But it's not a loop, so I can't add thumbnails to my related recipes. Is there a way with this plugin to make a custom loop that <a href="http://codex.wordpress.org/Custom_Post_Types#Querying_by_post_type" rel="nofollow">queries a custom post type?</a> 'if ( function_exists( 'the_related' ) ) { the_related( get_the_ID(), array( 'usept' =&gt; array( 'recipe' =&gt; true ), 'storage_id' =&gt; 'better-related-recipe' ) ); }'
        Reply to this comment
        • avatar
          nicolas wrote this comment on Dec. 7, 2010, 7:17 p.m.
          Seriously? Did you miss the "How to build a custom loop of related posts" section? Just add your post type to $args.
          Reply to this comment
          • avatar
            Thompson wrote this comment on Dec. 7, 2010, 7:44 p.m.
            That last sentence is what I needed. We're not all programmers. Of course I saw the section, hence my original question of how to define the custom post type to use. And the answer is to add your custom post type to $args. Thx.
            Reply to this comment
  • avatar
    Michael wrote this comment on Nov. 29, 2010, 2:17 p.m.
    Hi Nicolas. I've implemented your great plugin, but in the results i see private declared articles too. Thats realy not good. Ok, the articles are not accessible for the users without the rights, but i do not want, that the headers are showed in my public area. how i can prevent this? Is a secret option available for this? best regards Michael
    Reply to this comment
    • avatar
      nicolas wrote this comment on Nov. 29, 2010, 2:44 p.m.
      Hi Michael. No, this is not configurable at the moment, but I will add this feature in the next release. If you're comfortable with PHP you could edit lines 300 and 463 in inc/scorer.php to exclude them from the SQL query as a quick fix.
      Reply to this comment
  • avatar
    Brent wrote this comment on Dec. 2, 2010, 10:51 p.m.
    Hi Nicolas, I have a quick question that your plugin may cure but I'm not sure, I was hoping you could give me some insight. On this page http://waterworks-lamson.com/authorized/ I have an "authorized dealer" search plugin set up that when you type the state in the search box "california" it will return the results (post)california then you have to click on that to get to the post. I would like to bypass the results page that you need to click on and go directly to the post. Is this possible? And..... I would like to only have the search on this (page). I hope you can help.... boy do I need it! Thank you for your time! Brent
    Reply to this comment
    • avatar
      nicolas wrote this comment on Dec. 4, 2010, 8:54 p.m.
      Well, I think that should be possible, but it depends a little on how your site was coded. I assume you had somebody build it for you, you could just ask that person to look into this or you can use my contact form if you're interested in hiring me :-)
      Reply to this comment
  • avatar
    Mistercyril wrote this comment on Dec. 4, 2010, 11:22 a.m.
    Hello Nicolas, I am trying to display custom post type thumbnails, but I can't get this to work. Could you tell me how to re-write frontend.php (L. 480...) to display my custom post type thumb? I call my thumbs like this: cp_get_image($post-&gt;ID, 'ad-thumb', 1); I would really appreciate the help... I just can't get it to work :-( Thanks, C.
    Reply to this comment
    • avatar
      nicolas wrote this comment on Dec. 4, 2010, 8:55 p.m.
      Hi, did you have a look at the readme.txt? It has examples for custom loops. cp_get_image() doesn't seem to be a wp function btw.
      Reply to this comment
      • avatar
        Mistercyril wrote this comment on Dec. 6, 2010, 6:46 p.m.
        Hello, Yes I looked at your read me file but I can't get your example to work with custom post type images, which is the whole point of using your plugin versus YARP. cp_get_image() is a custom function that works when I need to display thumbnails in the sidebar or anywhere in the posts so I know that it can be called. I'm just really fuzzy about this whole custom post system so I would appreciate the guidance. I'm sure many more people will be interested in knowing how to do this over time ;-) Thanks for understanding, C.
        Reply to this comment
        • avatar
          nicolas wrote this comment on Dec. 6, 2010, 9:27 p.m.
          Custom post types aren't different from normal posts in regard to thumbnails. The "How to build a custom loop of related posts" in the readme.txt features post thumbnails. Maybe I can help more if you ask a more specific question. Oh, and you should not hack the plugin files btw, everything can be done in a custom loop. If you find any limitation let me know and I'll see what I can do.
          Reply to this comment
  • avatar
    Dietrich wrote this comment on Dec. 7, 2010, 8:29 a.m.
    Hi Nicolas, I manage a site with about 3000 posts: http://personensuchpool.de but no related posts will be shown. All your requirements are fulfilled: php5, mysql5. I deactivated other plugins but nothing and there are a lot of related ones. What do I wrong. Thank you Dietrich
    Reply to this comment
  • avatar
    Joe wrote this comment on Dec. 8, 2010, 1:02 a.m.
    Cool plugin! I set up a custom loop with thumbnails. Is there a way to show related items with thumbnails before those that don't have one? Or to show only related items that have thumbnails?
    Reply to this comment
    • avatar
      nicolas wrote this comment on Dec. 8, 2010, 2:39 a.m.
      Yes sure, see http://codex.wordpress.org/Function_Reference/has_post_thumbnail for the latter. For the former you can store the posts with thumbnail in an external var or loop through your posts twice, see http://codex.wordpress.org/The_Loop
      Reply to this comment
      • avatar
        joe wrote this comment on Dec. 8, 2010, 5:48 a.m.
        Thanks. For some reason I couldn't get has_post_thumbnail to work wherever I tried to integrate it (I must've not found the proper place to use it in my custom loop.) But I was able to get it to work by adding this to the array of argument: ''meta_key' =&gt; '_thumbnail_id',' From: http://wordpress.org/support/topic/display-the-post-only-if-thumbnail-is-set-up Your other option sounds cool, but is way over my head. Just wanted to post this in case it helps others. http://wordpress.org/support/topic/display-the-post-only-if-thumbnail-is-set-up#post-1769764 One last question, if you’d be so kind. If, for instance, only 2 related posts are displayed with thumbnails, can a custom loop be set up to automatically display 3 random posts with thumbnails to fill out all 5 areas? This may be a hard one.
        Reply to this comment
        • avatar
          nicolas wrote this comment on Dec. 8, 2010, 4:47 p.m.
          This plugin doesn't show random posts. But you can probably just store the post IDs of the first loop and start a second loop that excludes those posts. See http://codex.wordpress.org/Function_Reference/query_posts for random order IIRC
          Reply to this comment
  • avatar
    Joe wrote this comment on Dec. 10, 2010, 12:07 a.m.
    I got it to work! Thought I'd share. I set up two loops, and somehow figured out how to set up a counter, so that the second loop returns only enough thumbnails to fill in 5 total thumbnails in case fewer than 5 related items exist. This way there are always 5 thumbnails and it looks great. It's only missing one thing, an argument to exclude the current post itself on which these are displayed from being returned as a thumbnail. But I tried everything and haven't found an argument that works. But it's still pretty darn well. Works for me. Thought it might help others and wanted to share. <strong>Edit</strong> Sorry, I had to remove your code. WordPress is really lousy when it comes to code in comments. Can you pastebin your code? I'll be able to have a look then.
    Reply to this comment
    • avatar
      Joe wrote this comment on Dec. 10, 2010, 5:36 p.m.
      http://pastebin.com/kMc78FEj Give this link a try. My code looks a little messy, so if you see a way to improve upon it, like excluding the current post, I'd love to hear.
      Reply to this comment
      • avatar
        Joe wrote this comment on Dec. 11, 2010, 1:35 a.m.
        BTW, when I turn on WordPress' debug in wp-config, my code gives this notice: Notice: Undefined variable: do_not_duplicate The code obviously works. So it's not a big deal. But should I just set the variable equal to zero right before using it, so it's defined?
        Reply to this comment
        • avatar
          nicolas wrote this comment on Dec. 11, 2010, 11:27 a.m.
          Well, notices aren't so bad. Just define the variable before trying to access it. Like, $foo = array() etc.
          Reply to this comment
  • avatar
    xiaoyu wrote this comment on Dec. 27, 2010, 2:50 p.m.
    Hi, I have using your the plguin. but it is show some wrong in admin panel. I am using mysql 5.1.54 and your plguin v0.4.3.3. "There is no fulltext index for wp_posts.post_content There is no fulltext index for wp_posts.post_title"
    Reply to this comment
    • avatar
      nicolas wrote this comment on Dec. 27, 2010, 3:11 p.m.
      Your database probably doesn't use the MyISAM engine, which is the default for mysql. You should probably talk to your admin/hosting provider. This plugin will only support databases that support fulltext indexes. See the comments by Leonardo for how to test which MySQL engine you're using.
      Reply to this comment
    • avatar
      nicolas wrote this comment on Dec. 27, 2010, 3:19 p.m.
      I just see that InnoDB has been made the default with MySQL 5.5. You could <a href="http://dev.mysql.com/tech-resources/articles/storage-engine/part_1.html" rel="nofollow">change the engine for wp_posts</a>. I guess I could easily attempt to change the storage engine of the relevant table after asking for user permission. I'll be include such a feature in the next release.
      Reply to this comment
      • avatar
        Darko wrote this comment on July 1, 2011, 9:40 a.m.
        Current version still has this problem with:
        There is no fulltext index for wp_posts.post_content
        There is no fulltext index for wp_posts.post_title

        I am using WP 3.2 RC3, and since 3.2 minimum requirements for Wordpress is MySql 5.0. I guess that's the problem, engine is InnoDB on all tables... be sure to fix it before 3.2 goes official :)

        I went to PHPMyAdmin and changed the engine of 'posts' table to MyISAM, and your plugin works perfectly now :)
        Reply to this comment
      • avatar
        xiaoyu wrote this comment on Dec. 27, 2010, 3:25 p.m.
        I think should use InnoDB,so mysql offical choose. we have to use InnoDB. I have plan update to mysql v5.5. I have try mysql5.1 to5.5. but it is has some issue.
        Reply to this comment
      • avatar
        nicolas wrote this comment on Dec. 27, 2010, 3:42 p.m.
        I'll have to look into the reasons why MySQL decided to use InnoDB by default. If you can't switch the content table to MyISAM this plugin isn't for you, at least not at the moment. This plugin uses fulltext indexes for the search, which InnoDB doesn't have. I'll keep an eye on the future development. By the way, MySQL changing the default storage engine will only affect new databases, not existing ones.
        Reply to this comment
      • avatar
        xiaoyu wrote this comment on Dec. 27, 2010, 4:52 p.m.
        I remember mysql offical said will give up MyISAM. This is a long time ago what they have decided. So I am use InnoDB. though I like the MyISAM easy backup.If I use MyISAM,then will not easy for mysql upgrade. now your plguin work in my WP blog. but I do not know what effect that error.
        Reply to this comment
  • avatar
    vijay dubey wrote this comment on Dec. 28, 2010, 3:03 p.m.
    thanks Nicolas for this plugin... Currently I am using YARPP but I am planning to replace that with the plugin developed by you...i have one question though (a noob here)..I want to use a thumbnails in the related posts..can you guide/suggest me how to do that. Thanks
    Reply to this comment
    • avatar
      nicolas wrote this comment on Dec. 30, 2010, 6:34 p.m.
      Do you know how to build a normal loop with post thumbnails? Do you actually use the post thumbnail feature? If so, there is an example of a loop in the readme.txt iirc.
      Reply to this comment
  • avatar
    thomaz wrote this comment on Dec. 30, 2010, 9:18 p.m.
    Hello Nicolas, I'm having this problem with the plugin: I'm trying to use the plugin to a post type called "Events", but it is showing only the posts of "events" are marked with the same taxonomy. I want him to show all posts "Events", regardless of their taxonomies. There's how to do this? Thanks for the plugin. Hug.
    Reply to this comment
    • avatar
      nicolas wrote this comment on Jan. 3, 2011, 4:38 p.m.
      Did you check the analyze function yet? Maybe the contents of your events just aren't related enough? Also, the plugin only checks relatedness in the post_content field, not in any custom fields.
      Reply to this comment
  • avatar
    Ebi wrote this comment on Jan. 8, 2011, 2:26 p.m.
    hi 1st of I have to thank u for the great plugin ! it's really useful ! I got question : How can I insert it in my template and remove the automatic related links just after the post ? I wanna place it after the post block Thanx
    Reply to this comment
  • avatar
    iip albanjary wrote this comment on Jan. 20, 2011, 5:06 a.m.
    Hi nicolas, your plugin is nice, but after I installed for about two weeks, I can't display my preview post, even single post I. the error massage: Allowed memory size of 33554432 bytes exhausted (tried to allocate 30720 bytes) in .../public_html/wp-content/plugins/better-related/inc/scorer.php on line 382 now I'm deactivating the plugin and waiting your advice. thanks
    Reply to this comment
    • avatar
      nicolas wrote this comment on Jan. 20, 2011, 2:15 p.m.
      Hi, you'll have a hard time trying to get any plugins to work with 32MB. You should probably look into getting a better hosting package with more RAM. You could try to reduce the query limit and to activate incremental scoring.
      Reply to this comment
      • avatar
        Csaba wrote this comment on Feb. 1, 2011, 12:39 a.m.
        Exactly the same experience. PHP allowed size is same as above. Every othee plugin works like a charm. I tried to lower query limits. It allowed me to lower them to 100 (Query limit) and 200 (Total Query limit) , I also activated incremental scoring. But doesn't work. Failed to show the page at all. It started when the number of posts raised. There are currently about 8000 posts in the blog. Any suggestion ?
        Reply to this comment
        • avatar
          nicolas wrote this comment on Feb. 1, 2011, 1:57 p.m.
          Well, I don't think this is something I can do much about. 32MB is really not enough to run many plugins. You could try the YARP plugin, maybe that works.
          Reply to this comment
  • avatar
    Dominik wrote this comment on Jan. 30, 2011, 6:31 p.m.
    Hi, there is a problem with the admin backend: it doesn't seem to escape the values it tries to insert into the form. Try using &lt;strong style="color:red"&gt;Related Posts&lt;/strong&gt; in the title field. The value is saved correctly but when the form shows up again its broken.
    Reply to this comment
  • avatar
    Fanatic wrote this comment on Feb. 26, 2011, 4:08 p.m.
    Hi Nicolas, I just installed your plugin and was very impressed since it actually recognized the custom posts and ads through the admin settings panel in the classified theme that I'm using (ClassiPress from AppThemes), although when I test drive it on the front end, I always end up with "No related content found" despite checking all the custom fields in the settings and this theme explicitly uses the custom post types yet no results :( post page ad_listing category post_tag post_format ad_cat ad_tag I'm on a dedicated server so no DB issues, using WP 3.1 latest update and using ClassiPress theme. Admin preview: http://www. appthemes.com/demo/?theme=classipress-admin
    Reply to this comment
    • avatar
      nicolas wrote this comment on March 1, 2011, 11:59 a.m.
      Did you try the analyze tag yet? It's usage is described in the readme.txt.
      Reply to this comment
      • avatar
        Fanatic wrote this comment on March 1, 2011, 8:59 p.m.
        No I haven't and I just realized that the plugin actually worked but only under the main Blog posts and not the custom posts and custom categories, I'll try the Analyze tag attempt and update you with the outcome. Thanks Nicolas.
        Reply to this comment
  • avatar
    Thompson wrote this comment on March 2, 2011, 7:45 a.m.
    Hi Nicolas, Do you know what this warning might mean in regards to the code listed below it? Warning: array_keys() [function.array-keys]: The first argument should be an array $posts = array_slice( array_keys( $scores ), 0, 5 ); // keep only the the five best results Is this happening because no related items are found?
    Reply to this comment
    • avatar
      nicolas wrote this comment on March 3, 2011, 2:49 p.m.
      Hm, I'm not sure right now, but I'll look into this.
      Reply to this comment
    • avatar
      Benjamin wrote this comment on Sept. 1, 2011, 9:58 a.m.
      Hi Nicolas.
      Thank a lot for your superbe plugin - very helpfull.
      Unfortunately I am faceing the same problem like Thompson getting the following error messages:
      Warning: array_keys() [function.array-keys.php]: The first argument should be an array
      Warning: array_slice() expects parameter 1 to be array, null given
      I copied your code example as it is from the readme.txt file and added a custom post type.
      I would highly appreciate your help in this matter.
      Thanks, Benjamin
      Reply to this comment
      • avatar
        Nicolas Kuttler wrote this comment on Sept. 2, 2011, 1:11 p.m.
        Please pastebin your code and post a link.
        Reply to this comment
        • avatar
          Benjamin wrote this comment on Sept. 2, 2011, 7:24 p.m.
          Hi Nicholas Thanks for your quick answer. I have the following code inserted:
          <?php
          $scores = the_related_get_scores($post->ID, true);
          $posts = array_slice( array_keys( $scores ), 0, 6 );
          $args = array('post__in' => $posts, 'post_type' => 'teppich', 'posts_per_page' => 6 );
          $my_query = new WP_Query( $args );
          if ( $my_query->have_posts() ) {
          while ( $my_query->have_posts() ) {
          $my_query->the_post();
          $url = get_bloginfo('url');
          $directory = get_bloginfo('template_directory');
          $orderid = get_post_meta($post->ID, 'order-id', true);
          echo '<li><a href="' . $url . '/teppich/' . the_slug( get_the_ID() ) . '"><img src="' . $directory . '/teppiche/' . $orderid . '.jpg" /></a></li>';
          } } else { echo "No posts found..."; } ?>


          An example of the page you'll find on http://karpet.ch/redesign/teppich/almaty/
          I adjusted the code slightly, but even with the code from your readme.txt file, i got the same problem.
          Below the the «Diese Shyrdaks werden Ihnen auch gefallen» 6 related items should be listed within the slider.
          The weird thing is, that sometimes it works but most of the time i get the above mentionned error message.
          Thank you so much for your kind help. A donation for your superbe plugin will be for sure..! ;o)
          Regards from Switzerland,
          Benjamin
          Reply to this comment
          • avatar
            Nicolas Kuttler wrote this comment on Sept. 5, 2011, 10:47 a.m.
            I think the problem is that the_related_get_scores() returns null (or false, not sure how I coded that). So you should probably check if $scores is_array() before you run the rest of the code.

            Reply to this comment
  • avatar
    Ian Sampaio wrote this comment on March 3, 2011, 12:42 a.m.
    Hi, is it possible to use it with special post (post type). I'm using post type to differ products from regular blog both in front and back end.
    Reply to this comment
  • avatar
    Daniele wrote this comment on March 3, 2011, 10:39 a.m.
    Hi Nicolas, I've already read the readme.txt file and all comments above, but I've a doubt about using taxonomy. Say I have 2 different posts types, A and B, and a custom hierarchical taxonomy named "type", defined on both. If I use a configuration like this: http://w3b.pastebin.com/v0erkGFN should I get a selection of related posts from A to B (and viceversa), only if they SHARE THE SAME TERMS under "type" taxonomy, ? In other words, for a post in A (or B), can I get a list of related posts, but only selected among B (or A) posts classified with the same terms under the same taxonomy? Thanks in advance, Daniele.
    Reply to this comment
    • avatar
      nicolas wrote this comment on March 3, 2011, 2:54 p.m.
      Hi Daniele, hm, I don't think so. It's been a while I've worked on this code but I don't think you can query only one post type. What you could do is to filter by post type in the loop that displays the results though (I guess). For the next major release I wanted to rewrite the taxonomy scoring anyway, so I'll look into this. Thanks for the idea.
      Reply to this comment
  • avatar
    Angelo wrote this comment on March 12, 2011, 4:54 p.m.
    I can't activate che plugin. I'm using the WP 3.1 and the plugin Version 0.4.3.3. I also have Custom Post Type UI, Custom Field Template, Header and Footer and Tweet Import activate. ####################### Plugin could not be activated because it triggered a fatal error. Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /nfs/c01/h16/mnt/6224/domains/sodastudio.it/html/wp-content/plugins/better-related/better-related.php on line 44
    Reply to this comment
  • avatar
    Dean Ricca-Smith wrote this comment on March 16, 2011, 2:39 p.m.
    hi nicolas - huge thanks for making a plugin that works with custom post types - quick question: my client has 3 distinct areas on the site - 3 blogs if you like - I filter these using categories - trouble is i use the category 'featured' across all 3 areas so it is relating blog posts just because they share 'featured' category is there any way I can say 'ignore the 'featured' category' when scoring? many thanks again
    Reply to this comment
    • avatar
      nicolas wrote this comment on March 16, 2011, 4:37 p.m.
      Hi Dean, sure, it's documented in the readme.txt. There are various scoring options you can disable/enable.
      Reply to this comment
      • avatar
        Dean Ricca-Smith wrote this comment on March 16, 2011, 4:43 p.m.
        You can do this for just one specific category? by category ID? I thought you could only add/reduce weighting for all categories?
        Reply to this comment
      • avatar
        Dean Ricca-Smith wrote this comment on March 16, 2011, 5:14 p.m.
        thanks for your replies ideally I'd like it to ignore for example Category ID6 for scoring but not penalise any post if it has that category. my test site is here if you want to see [edit: 404] anything that is 'Featured' category is what gets sent to the slideshow - which build a 'false' relationship
        Reply to this comment
  • avatar
    Angelo wrote this comment on March 18, 2011, 1 p.m.
    "There is no fulltext index for wp_posts.post_content There is no fulltext index for wp_posts.post_title" How I can solve this error?
    Reply to this comment
  • avatar
    Mike Cruse wrote this comment on March 19, 2011, 3:39 a.m.
    Greetings Nicolas! This is a great plugin. I have read this thread carefully and verified, that I am running PHP5 with MySQL 5.0.32. All tables are MyISAM. The plugin is creating FULLTEXT indexes called post_content_index and post_title_index for the post_content and post_title fields. I have even dropped and created the indexes by hand and used the code you suggested above. I received no errors in that process. My host will not be updating our MySQL version (grid based) for several months so I am stuck with it for now. Unfortunately, I still receive the below error. Do you have any other thoughts? There is no fulltext index for wp_posts.post_content There is no fulltext index for wp_posts.post_title Thank you very much! Mike
    Reply to this comment
    • avatar
      nicolas wrote this comment on March 19, 2011, 2:32 p.m.
      Hm, that's odd. If the indexes exist maybe my code to detect them is buggy. Did you try to output related posts on the frontend? I'm not sure if the plugin would try to display them even without indexes detected. What you can try is to add a <code>return true;</code> on line 223 of better-related.php to bypass the index detection. Please do tell me if the plugin works then, as that would be a rather annoying bug :-|
      Reply to this comment
      • avatar
        Tim wrote this comment on April 2, 2011, 5:19 a.m.
        Same/similar issue here. When I inserted "return true;" on line 223 the plugin worked great.
        Reply to this comment
      • avatar
        Michael Cruse wrote this comment on March 20, 2011, 10:12 p.m.
        Nicolas, I was able to get this corrected. It was not a problem with you plugin but with my database. I asked my host to take a look at the MySQL server and they corrected or changed something. Thank you for your comments and a great plugin! Mike
        Reply to this comment
      • avatar
        nicolas wrote this comment on March 21, 2011, 12:18 p.m.
        Glad to hear it works :-)
        Reply to this comment
  • avatar
    Chanery wrote this comment on March 26, 2011, 10:01 a.m.
    Hi Nicolas,

    Your plugin is really perfect. It is no doubt the best among all the similar plugin.

    I have encountered a problem that I am unable to resolve hoping you can kindly help on it.

    My blog can set the post to be automatically outdated for a period of time and the updated post will not be shown publicly.

    However the related post plugin can find the related OUTDATED post and show up the OUTDATED post title.

    How can I exclude those OUTDATED post from the related post result? Or do not show post more that a period of time, say 30 days?

    Many Thanks in advance.
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on March 26, 2011, 11 p.m.
      The readme.txt has examples on how to build custom loops. That should make it easy to exclude some posts.
      Reply to this comment
      • avatar
        Chanery wrote this comment on March 27, 2011, 6:52 p.m.
        In the scorer.php

        Line 300, I change to:

        WHERE ( post_status='publish')

        from:

        WHERE ( post_status='publish' OR post_status = 'private' )

        And Line 463 I change to:

        AND ({$prefix}posts.post_status = 'publish')

        from:

        AND ({$prefix}posts.post_status = 'publish' OR {$prefix}posts.post_status = 'private')

        But it is still showing the private posts. What should I do?

        MANY THANKS!
        Reply to this comment
        • avatar
          Nicolas Kuttler wrote this comment on March 27, 2011, 9:39 p.m.
          Did you clear the score cache? You can do it on the options page.
          Reply to this comment
          • avatar
            Fabien wrote this comment on Oct. 27, 2011, 2:52 p.m.
            Hi,

            I do you clear the score cache ?

            Indeed I still can see private posts...
            Reply to this comment
  • avatar
    Chanery wrote this comment on March 26, 2011, 10:27 a.m.
    To follow up my previous comment.

    My question is how to exclude the "Privately Published" post?

    THANKS!
    Reply to this comment
  • avatar
    Kallan wrote this comment on April 3, 2011, 5:18 p.m.
    I really love Better Related Posts. It pulls in all the content I want it to seamlessly. But there is another related posts plugin that I am tempted to use in place of Better Related Posts: Related Post Thumbnails! I love the plugin because of the thumbnails feature, but it just doesn't pull in "related" posts like Better Related Posts does. Think you could add optional thumbnail functionality? I really like how well Better Related Posts, but it just isn't "pretty" enough. Great job on it though; it's the best one I've found!

    Thanks,

    Kallan
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on April 3, 2011, 5:26 p.m.
      Hello Kalan. No, I prefer to keep this plugin lean. However, adding thumbnails to the list display is very easy and there's even an example in the readme.txt on how to do it.
      Reply to this comment
  • avatar
    Dean Ricca-Smith wrote this comment on April 6, 2011, 4:36 p.m.
    hi nicolas

    I'm making heavy use of custom meta fields in my site - and importing data into them from a Filemaker database

    When I look at my database tables every custom field seems to have a duplicate - so I end up with one populated by filmmaker and one empty

    Can i just check whether your plugin needs there to be duplicates of custom fields to work? Would your plugin duplicare custom field data in the wordpress database?

    any help greatly appreciated
    Reply to this comment
  • avatar
    Nicolas Kuttler wrote this comment on April 6, 2011, 7:32 p.m.
    Hi Dean. This plugin uses the post meta to store relatedness scores. It stores all of them in one meta field, so it doesn't duplicate fields. The default field name would be something like better-related.
    Reply to this comment
  • avatar
    Nick wrote this comment on April 8, 2011, 2:51 a.m.
    Thanks for the plugin- if I can get it working, it will be the only one that can handle custom post types and related posts.

    But I cant get it to work with custom post types.

    It is displaying related content just fine with related pages and posts, but it is not displaying any related content from my custom post type 'events'. I have read the readme 20 times and all forums/comments. Can you help?
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on April 13, 2011, 10:20 a.m.
      Check the plugin options page and select your custom post types? That should do.
      Reply to this comment
  • avatar
    yabanga wrote this comment on April 11, 2011, 3:04 p.m.
    Hello,

    When I try to activate the plugin, I'm back with "plugin is enabled"but it remains off the list and I found nowhere menu for the parameter, and front "Call to undefined function"

    ???

    Thank you for your help.

    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on April 13, 2011, 10:20 a.m.
      Can you post the complete error? Are you maybe running an outdated WordPress version or PHP4?
      Reply to this comment
  • avatar
    jens wrote this comment on April 28, 2011, 5:01 p.m.
    Hi Nicolas,

    Is it also possible to show your plugin as a widget?
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on April 28, 2011, 10:09 p.m.
      Hm, I haven't included a widget. You could <a href="http://codex.wordpress.org/Widgets_API">give it a try yourself</a>, writing a simple widget isn't too hard.

      You might have to save the post ID into a variable and use it with the <tt>the_related_get_scores()</tt> call, I'm not sure if global $post is still set after the loop.
      Reply to this comment
  • avatar
    Dean Ricca-Smith wrote this comment on May 3, 2011, 1:37 p.m.
    hi again Nicholas

    I asked this above but was not sure I was clear on on my question"

    Can you remove one specific category from influencing the score?

    I have lots of posts that use the category 'Featured' to send them to a home page slideshow but they are not related. The plugin obviously thinks they are.

    So - is there any way to tell the plugin to ignore JUST the 'Featured' category for scoring purposes?

    Hope you can help

    Dean

    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on May 9, 2011, 12:21 p.m.
      Hmmm, I don't think this is possible, but I'd have to check the source code again. Pretty busy at the moment though, sorry about the late reply.
      Reply to this comment
  • avatar
    Nicole wrote this comment on May 15, 2011, 3:11 p.m.
    Hi, I've read through all the comments here and the readme.txt but I can't seem to get this to work quite right.

    When I use the plugin to automatically embed the related posts, it works fine but I can't get the manual insert with a custom loop to work.

    I need to call the plugin only on the single post pages for my 'work' custom post type, and want it to pull custom posts from the 'artists' custom taxonomy. It works find when I use the settings in the admin panel but with - as far as I can gather - the same settings manually coded in it's only calling regular posts that don't share the 'artists' taxonomy.

    This is the code I'm using: http://pastebin.com/HAJw1c5M
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on May 15, 2011, 3:23 p.m.
      You are passing $args to WP_Query that you should pass to the_related_get_scores(). WP_Query doesn't know what to do with any of these.

      You need the_related_get_scores( get_the_id(), $args ), and to pass the result of that as 'post__in' parameter to WP_Query.
      Reply to this comment
  • avatar
    Topan wrote this comment on May 16, 2011, 3:34 p.m.
    Hi Nicholas,
    I've read the readme.txt. But I do not find how to exclude certain category or tags of my post.
    Example: i wanna hide related post from category "video".
    Can i ? What code should i write on the single.php ?
    Thanks. I'm sorry i can't speak english well.
    Hehehe..
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on May 18, 2011, 8:08 p.m.
      I think you can do that by just passing the necessary parameters to the WP_Query (if you build a custom loop like described in the readme.txt)
      Reply to this comment
      • avatar
        Topan wrote this comment on May 20, 2011, 3:01 p.m.
        I really newbies Mr. Nicolas. I'm not a Superp Programmer like you. I still dont understant what u describe in readme.txt. Can u write that code here. So i can just copy and paste it to my single.php ?
        GOD BLESS YOU.
        Reply to this comment
  • avatar
    Anton Bielousov wrote this comment on May 30, 2011, 9:11 a.m.
    This plugin shows the best post selection among other related posts plugins so I stoped on it. But is there any way to force one post alway to appear for another post i.e. to set some custom field like related_post_1 = URL ?

    If there is, I could not find it, if not, I think it would be a great idea to add it.

    Any way, here's your plugin in action: http://www.bielousov.com/2011/toronto-lollipop/
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on May 31, 2011, 8:50 a.m.
      There's no built-in way to do this at the moment, no. If you know a little about wp coding you could probably just use a custom field and use that for the custom loop you build.
      Reply to this comment
  • avatar
    Leanda Ryan wrote this comment on May 31, 2011, 8:14 p.m.
    I've got two post types set up and each has the same set of custom taxonomy.

    For example one post type is called 'Events' and another called 'Training' and then both post types have the same set of taxonomy. I'm looking for a way to cross reference posts.

    With this plugin is it possible to get the taxonomy from the current post, but then display related posts from the other post type with that same taxonomy name?

    Thanks
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on June 1, 2011, 10:20 p.m.
      Yeah. In fact that's the default behavior. If you select taxonomies to include in the relatedness score each term of every taxonomy is checked against every term from all other selected taxonomies.

      It's actually a bug, but a small and sometimes useful one so I haven't fixed it yet. I'll probably keep this as the default behavior in the future as well as some people might depend on it.
      Reply to this comment
  • avatar
    Lane wrote this comment on July 10, 2011, 5:43 a.m.
    Great Plugin! Just a small bugfix

    I was getting a PHP warning notice: Undefined variable: r in .../better-related/inc/frontend.php on line 169
    when there were no related posts found.

    FIX:
    if (isset($r)) return $r;

    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on July 11, 2011, 9:34 p.m.
      Thanks, I'll keep this in mind when I work on the next release.
      Reply to this comment
  • avatar
    Navjot Singh wrote this comment on July 20, 2011, 10:57 a.m.
    Just noticed that to display just 5 related posts on a blog, your plugin adds 17 SQL queries on a single post page. Isn't that too much? If you can optimize them to a more manageable number then it would be great.
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on July 20, 2011, 1:52 p.m.
      The plugin should cache all related posts it finds until you publish a new post. The number of queries also depends on the scoring methods you use.

      17 queries itself isn't a problem at all. It can be a problem if those 17 queries have to go through a post table with a million posts though. That's why there's a query limit and incremental scoring.
      Reply to this comment
  • avatar
    Upekshapriya wrote this comment on July 25, 2011, 3:02 p.m.
    I can't seem to activate the plugin on Wordpress 3.2.1 with all other plugins disabled and with Twentyeleven theme. Any chance of making it compatible?
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on July 26, 2011, 9:37 p.m.
      Do you get some error message?
      Reply to this comment
      • avatar
        Upekshapriya wrote this comment on July 26, 2011, 11:43 p.m.
        Wordpress produces no error messages - all I get is a message saying it is activated but when I look at the plugins list Better Related Posts plugin still has the activate option available.
        Reply to this comment
  • avatar
    Glass wrote this comment on July 26, 2011, 1:28 a.m.
    Great code! I noticed in the files you disabled attachments as an option. I'm using another plugin (http://wordpress.org/extend/plugins/media-tags/) that uses custom taxonomies assigned to attachments. I hope someday you decide the plugin will support attachment relations. It would be great to have related images!
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on July 26, 2011, 9:36 p.m.
      That's a great idea! Unfortunately I'm not using wordpress for my own sites any more, so there's only the small chance a client would need this feature and allow me to release the upgrade.
      Reply to this comment
  • avatar
    oliver wrote this comment on Aug. 1, 2011, 8:32 a.m.
    Hello,
    first of all: great plugin.
    Is there a way to display an excerpt following the related links?
    It would be great if it is possible to show the normal excerpt of the post (or a certain count of words of the content section)...
    Best regards,
    Oliver
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Aug. 3, 2011, 12:34 p.m.
      Yes this is possible, but you'll need to write a few lines of PHP code. It's documented in the readme.
      Reply to this comment
  • avatar
    Rahl wrote this comment on Aug. 12, 2011, 7:28 p.m.
    Hi Nicolas,

    Does this work with WP MultiSite Network.

    Is it compatible across network?

    Thank You!
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Aug. 14, 2011, 10:16 a.m.
      It depends on what you mean? Sure, it works on blogs inside a network. However, it doesn't give you related posts from other blogs in the network.
      Reply to this comment
  • avatar
    Mixette wrote this comment on Aug. 29, 2011, 4:38 p.m.
    Hi Nicolas,

    I'm using the custom code from the readme text (first example), but I can't get it to display the related post titles. It keeps saying 'no posts found'.
    Though in the $posts array all the post id's are ok (eg
    <?php Array ( [0] => 238 [1] => 428 [2] => 579 [3] => 606 [4] => 486 );?>



    <?php the_related();?>

    works fine, but I would like to use the custom code to display some metabox fields from a custom post type.

    Am I missing something? I'm not a coder, could you help me out a little bit?
    Thanks!
    Britt
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Aug. 30, 2011, 6:06 p.m.
      Hrm, can you paste your whole code here or on a pastebin site? Not really sure what's going on here.
      Reply to this comment
  • avatar
    Toine wrote this comment on Sept. 1, 2011, 12:08 p.m.
    Hi Nicolas, great plugin! Good work :)
    Got one question though; is it possible to show only related posts from the same custom post type? I only want to use the post_tag for relevance, but if you haven't filled in any tags somehow they show up on other custom post type posts...
    Thanks!
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Sept. 2, 2011, 1:12 p.m.
      You can use the usept parameter for this. Please see the readme.txt
      Reply to this comment
      • avatar
        Toine wrote this comment on Sept. 2, 2011, 2:01 p.m.
        Yup, that did the trick! When using multiple configurations they will all use the variables set in the global plugin settings if you don't specify them right? Thanks again!
        Reply to this comment
  • avatar
    Omar Lee wrote this comment on Sept. 14, 2011, 6:01 p.m.
    Hi Nicolas,

    First, I would say thank you for making a great plugin. It solved a lot of my problems searching for related post plugin to display related videos of my site in which I realized it's using custom taxonomy. Other related post plugin doesn't work until I found yours.

    I just wonder on how to add a thumbnails to the results. I can only find the title link. I read your readme.txt but I don't know where i should start. I see this line in readme.txt:

    if ( has_post_thumbnail() ) {
    the_post_thumbnail( 'thumb' );
    }
    echo '<br>';

    I don't know if this is the line I am looking for and if it is,I don't know where to insert it, what file should I edit. Hope you can help me with this little problem. You are a great talented person.

    Thanks.
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Sept. 17, 2011, 2:09 p.m.
      Yes, this is the code to add the thumbnail. You just add it where you want to thumbnail to appear inside your loop. See http://codex.wordpress.org/The_Loop for an introduction.
      Reply to this comment
  • avatar
    zepar wrote this comment on Oct. 5, 2011, 10:55 a.m.
    hi, the plugin works great for me but I have one little problem in admin area.. I've entered at "Related posts title" the following: ~span style="background-color: #FFDECF;"~Related:~/span~

    After I saved changes, it appeared as '~span style=' in text area and 'Related:" size="60" /~' outside the editing area. I don't really need to change it right now but for the future, where should I look for editing this?
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Oct. 8, 2011, 11:38 a.m.
      Hm, not sure what you mean, but you should probably use your normal css stylesheet and add rules there.
      Reply to this comment
      • avatar
        zepar wrote this comment on Oct. 13, 2011, 11:29 a.m.
        hey, thank you for your answer. Let me make it easier to understand: how can I edit the text that is underlined with red in the following picture: http://img197.imageshack.us/img197/2434/betterrelatedcontent.png
        Reply to this comment
        • avatar
          Nicolas Kuttler wrote this comment on Oct. 17, 2011, 10:27 p.m.
          Oh, this might look like a bug. I'll look into a fix. I should have a little time soon.
          Reply to this comment
  • avatar
    mchl wrote this comment on Oct. 5, 2011, 2:19 p.m.
    Hi, yep i agree with everyones sentiment that this is great plugin, so thanks, but i seem to be having trouble getting it to work, good chance im overlooking something so was hoping you could offer some insight.

    When i have the plugin enabled to show up in default wp posts it works fine.

    But when i use a cpt with a default content editor and custom fields its returning 'No related content found' in that post type or for any other post type. ive tried with both the admin options and the manual options in the readme. I get the same result when i run the_related_analyze() too. Id does however return results for the default wp posts when i use the 'custom loop of related posts' example in a ctp.

    At a bit of lose and would be if you could offer some advise. Much Appreciated
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Oct. 8, 2011, 11:41 a.m.
      the_related_analyze() should show a lot of different scores IIRC. Don't you get any related value anywhere? Maybe it's a caching issue, there should be some reset scores option on the admin page (or change the storage key).
      Reply to this comment
      • avatar
        mchl wrote this comment on Oct. 10, 2011, 12:10 p.m.
        Yeah i only get 'No related content found.' on all the listed items when i call the_related_analyze(). Ive started with a fresh db, created a new ctp and added 2 new posts with related titles and content but still nothing is returned and i get 'No related content found'. Not sure what else to look for?? Thanks
        Reply to this comment
        • avatar
          Nicolas Kuttler wrote this comment on Oct. 17, 2011, 10:26 p.m.
          Hmmm, your cpt uses the normal editor, doesn't it. Maybe your posts are just so different that they aren't related to each other at all?
          Reply to this comment
  • avatar
    miri wrote this comment on Oct. 6, 2011, 8:27 a.m.
    Hi!
    The Plugin is very nice and used to work for me, but I recently changed my theme and since then the releated posts only show up in the single-post-view. Is there some solution?

    Thanks for all :-)
    Miri
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Oct. 8, 2011, 11:40 a.m.
      I think I add a filter on the_content to add the related posts. Maybe your theme is a little odd and doesn't use that default template tag. In the readme.txt is a method to place the related posts manually, you could try that.
      Reply to this comment
  • avatar
    Indezoo wrote this comment on Oct. 22, 2011, 6:03 p.m.
    this is really cool plugin...how can i edit the css for it to even show thumbnails for post too...thank you
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Oct. 24, 2011, 12:42 a.m.
      IIRC the readme.txt has an example of a custom loop.
      Reply to this comment
  • avatar
    Toine wrote this comment on Nov. 14, 2011, 5:32 p.m.
    Hi there,

    I'm getting some errors at the top of my related posts all of a sudden:

    Warning: array_keys() [function.array-keys]: The first argument should be an array in /path-to/single.php on line 69

    Warning: array_slice() expects parameter 1 to be array, null given in /path-to/single.php on line 69

    Warning: array_search() [function.array-search]: Wrong datatype for second argument in /path-to/single.php on line 79

    etc.
    But only on 1 certain post? In single.php line 69 looks like this:


    <?php
    $scores = the_related_get_scores(get_the_ID(), array( // Line 61
    'usept' => array(
    'post' => true
    ),
    'usetax' => array(
    'post_tag' => true
    )
    ));
    $posts = array_slice( array_keys( $scores ), 0, 5 ); // Line 69
    $args = array(
    'suppress_filters' => true,
    'post__in' => $posts,
    'posts_per_page' => 5,
    'caller_get_posts' => 1
    );
    $my_query = new WP_Query( $args );
    function orderby( $a, $b ) {
    global $posts;
    $apos = array_search( $a->ID, $posts ); // Line 79
    $bpos = array_search( $b->ID, $posts );
    return ( $apos < $bpos ) ? -1 : 1;
    }
    usort( $my_query->posts, "orderby" );
    ?>



    Any ideas on what might be causing the problems?
    The particular post on which the problem occurs has some <object> and <iframe> tags in it.

    Thanks for your help!
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Nov. 16, 2011, 5:24 p.m.
      I think that the the_related_get_scores() function can return false or something that's not an array when no related posts are found. So you should check if you get an array from it.
      Reply to this comment
      • avatar
        Toine wrote this comment on Nov. 17, 2011, 11:28 a.m.
        I do get an array from the_relatedget_scores(), because there are related posts underneath these warnings. I did som tests and it appears these warnings only occur when there are embed codes like <embed> and <iframe> in the post like soundcloud for example.

        I made a post on the wordpress forums for more detailed information:
        http://wordpress.org/support/topic/plugin-better-related-posts-embedcode-post-causing-warning-array_keys

        It's definetely plugin related because when I disable the plugin, or remove the php code, the warnings dissapear too.

        Any ideas?
        Reply to this comment
        • avatar
          Nicolas Kuttler wrote this comment on Nov. 20, 2011, 8:47 a.m.
          You should probably start by debugging every step of the code, using print_r(), var_dump() etc.
          Reply to this comment
          • avatar
            Toine wrote this comment on Nov. 22, 2011, 5:18 p.m.
            You mean my code in the single.php template or your plugin code?
            Because
            print_r($scores)

            returns nothing and
            var_dump($scores)

            returns 'NULL'.

            Weird, it only happens when the post content has some embed codes...
            Reply to this comment
  • avatar
    themojowill wrote this comment on Nov. 15, 2011, 11:47 a.m.
    Any plans to change this plugin to use InnoDB?
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Nov. 16, 2011, 5:22 p.m.
      Not likely, unless InnoDB gets support for mysql relatedness score for fulltexts
      Reply to this comment
  • avatar
    Jarga wrote this comment on Nov. 21, 2011, 11:37 p.m.
    Nice plugin ! It would be better if you include a widget...
    Thanks
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Nov. 22, 2011, 12:33 a.m.
      Feel free to submit a patch. Reminds me.. I have a few to review..
      Reply to this comment
  • avatar
    fonec wrote this comment on Nov. 22, 2011, 1:50 a.m.
    i am use your plugin
    when i am post my hand i am see related post like it
    http://fonec.info/?p=4055


    post posts which auto post by plugin
    FeedWordPress

    simple and flexible Atom/RSS syndication for WordPress


    related post not see like in links
    http://fonec.info/?p=4035
    http://fonec.info/?p=3590

    hope you understanding me
    and i am wait your help
    www.fonec.info
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Nov. 23, 2011, 12:42 p.m.
      Hmmmm... no I don't really understand what you mean.
      Reply to this comment
  • avatar
    fonec.info wrote this comment on Nov. 24, 2011, 4:25 p.m.
    posts come from using plugin FeedWordPress in that case not get realated posts
    link post in link
    http://fonec.info/?p=6706


    but when post from site by my self get reated posts
    like that post
    http://fonec.info/?p=6647

    hope understanding me
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Nov. 24, 2011, 5:11 p.m.
      Hm. No idea. Maybe the posts you feed into wp aren't related at all to your pervious content. I can't think of anything else right now as the plugin can search for related posts for every request on the frontend.
      Reply to this comment
  • avatar
    Indezoo wrote this comment on Nov. 30, 2011, 12:58 p.m.
    My problem is that i want to show my custom post type of portfolio...but somehow i am not able to get it work...i want to show thumbnails of the related portfolio item on single post page...you can check out my website http://www.indezoo.com for better understanding!!!
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Dec. 1, 2011, 10:43 a.m.
      Not sure what your question is. IIRC the readme has an example with thumbnails. If you get no related posts check the analyze function.
      Reply to this comment
  • avatar
    telebrain wrote this comment on Dec. 6, 2011, 11:30 a.m.
    Great Plugin, the only one that work very well.

    One question. I use the tag 'the_related_for_string' and set the limit to 9 post but the result is only 5 post. Any Ideas how to set the limit for this tag ?

    Thank you so much.
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Dec. 6, 2011, 6:03 p.m.
      Hi. You can pass the number of posts to return as second parameter. the_related_for_string('foo', 9). You can also pass a complete config as third parameter. Looks like this isn't in the readme yet.
      Reply to this comment
  • avatar
    Segovia wrote this comment on Dec. 30, 2011, 4:47 a.m.
    I've been trying to exclude private posts, pages and CPTs and have made edits to lines 300 and 463 as you suggested above and exactly as detailed by Chanery (on March 27, 2011 above). However I too was still seeing private posts in my results. Then I read about clearing the cache, but couldn't really figure out what you meant, until I found a setting in the options page for the plugin called "Data storage engine" (Post Meta or Transient). So I switched it to Transient and it fixed it, kind of, because now the private posts were eliminated from my results, however, when I change the setting back to "Post Meta" which sounds like the better option for the long term, all the private posts return.

    What am I missing? and how can I clear the cache? is this something i must manually do in the db table via phpMyAdmin? If so, I'm a bit clueless when it comes to editing DB's.

    Thanks, and I love your plugin. When are we going to see some updates from all the great ideas posted above?
    Reply to this comment
  • avatar
    Nicolas Kuttler wrote this comment on Dec. 31, 2011, 5:29 p.m.
    Isn't there something like a cache key you can configure? Or storage key maybe? Can't check at the moment, but changing that should clear the cache.

    I shall put the code on github so that everybody can contribute patches. I'll try to do that in the new year.
    Reply to this comment
  • avatar
    Christophe Depoire wrote this comment on Jan. 20, 2012, 3:59 p.m.
    Hi Nicolas, I can't find any information about using your related content plugin with a wordpress cache plugin, any advice? Better one? Not affected by external caching system?
    Thanks a lot.
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Jan. 22, 2012, 2:37 p.m.
      I don't think that using a cache plugin will affect this plugin in any way with the default configuration. Probably if you do incremental scoring.
      Reply to this comment
  • avatar
    Amro wrote this comment on Jan. 27, 2012, 11:02 p.m.
    Hey Nicolas ,

    This plugin is really awesome , thanks for your effort .
    I Have a small question , is there any code I can put in a certain post I don't want Related Posts to appear ?? Plus excluding this post from appearing on the related posts menu on other posts .

    Waiting for your reply :) .
    Thanks in Advance .
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Jan. 30, 2012, 9:38 p.m.
      Hi, you probably want to read the codex page on conditional tags? http://codex.wordpress.org/Conditional_Tags
      Reply to this comment
  • avatar
    Kyle Boddy wrote this comment on Jan. 31, 2012, 9:16 p.m.
    I switched to CloudFlare for performance reasons, and I think this is causing your plugin to no longer work. Do you know if that would affect your plugin from displaying posts? I keep getting "No related posts found" on all my posts when it would normally return many.
    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Feb. 2, 2012, 8:54 p.m.
      Hi Kyle, I'm afraid I don't know what cloudflare is or how it could affect my plugin.
      Reply to this comment
      • avatar
        judy wrote this comment on Feb. 9, 2012, 4:47 a.m.
        I have the same problem getting "No related posts found" on all my posts,do you give me some suggestion?
        Reply to this comment
  • avatar
    John wrote this comment on Feb. 19, 2012, 9:20 p.m.
    Awesome plugin!! :)

    Any idea why it's showing a blank <li> at the bottom of this page in the related articles section:

    http://www.partybuilders.com/ad-category/party-planners/

    I think it has something to do with the code from here, because I changed it from <ul> to <li> to see the dots in front. Any ideas?

    if ( !function_exists( 'the_related_for_string' ) ) {
    function the_related_for_string( $string, $maxresults = 5, $config = null ) {
    $scores = get_the_related_for_string( $string, $config );
    $listed = 0;
    foreach( $scores as $id => $score ) {
    if ( $listed >= $maxresults )
    break;
    if ( $score == 0 )
    break;
    $listed++;
    $link = get_permalink( $id );
    $title = get_the_title( $id );
    $post_type = get_post_type( $id );
    if ( !$title ) {
    $title = __(
    'This entry has no title',
    'better-related'
    );
    }
    $description = $title;
    $related .= "<li> <a href=\"$link\" title=\"Permanent link to $description\">$title</a></li>\n";
    }
    if ( @$related )
    echo '<ul>' . $related . '</ul>';
    elseif ( $relatednone = $config['relatednone'] )
    echo $relatednone;
    }
    }

    Reply to this comment
    • avatar
      Nicolas Kuttler wrote this comment on Feb. 20, 2012, 3:44 p.m.
      Thanks! Well... <li> is not the correct tag. Opera has a great page about HTML lists:

      http://dev.opera.com/articles/view/16-html-lists/

      You should also validate your HTML from time to time, see

      http://validator.w3.org/check?uri-charset=%28detect+automatically%29&uri-doctype=%28detect+automatically%29&ss=true&uri=http%3A%2F%2Fwww.partybuilders.com%2Fad-category%2Fparty-planners%2F
      Reply to this comment
      • avatar
        John wrote this comment on Feb. 21, 2012, 4:02 a.m.
        Thanks responding Nicolas.

        I switched it back to <ul>, but it just lists the content without putting the bullet. Any idea why it is doing that?

        http://www.partybuilders.com/ad-category/party-planners/

        Thanks,
        John
        Reply to this comment
        • avatar
          Nicolas Kuttler wrote this comment on Feb. 21, 2012, 3:34 p.m.
          Hi John, well that's a CSS issue. You should probably ask your theme developer.
          Reply to this comment

Start a new thread

Cancel reply
Markdown. Syntax highlighting with <code lang="php"><?php echo "Hello, world!"; ?></code> etc.