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.
I am Nicolas Kuttler, a web developer, system administrator and IT consultant from France, currently living in Germany.




I have the same problem and still no solution
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 :)
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
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
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.
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!
I do you clear the score cache ?
Indeed I still can see private posts...
My question is how to exclude the "Privately Published" post?
THANKS!
Thanks,
Kallan
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
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?
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.
Is it also possible to show your plugin as a widget?
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.
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
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
You need the_related_get_scores( get_the_id(), $args ), and to pass the result of that as 'post__in' parameter to WP_Query.
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..
GOD BLESS YOU.
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/
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
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.
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:
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.
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
Does this work with WP MultiSite Network.
Is it compatible across network?
Thank You!
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
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
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!
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.
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?
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
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
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:
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!
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?
Because
returns nothing and
returns 'NULL'.
Weird, it only happens when the post content has some embed codes...
Thanks
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
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
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.
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?
I shall put the code on github so that everybody can contribute patches. I'll try to do that in the new year.
Thanks a lot.
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 .
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?
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
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