Artikel vom 16. Oktober 2008
Related Posts by Category: The WordPress Plugin for Similar Posts
For on one of my favorite projects, das junge Magazin für Apple, I was looking for a WordPress plugin, which could find relevant articles and list them in order. Actually, I did not ask for much: Extreme performance, no extra storage capacities, and no fulltext search within the database. However I did not find any candidates. So I developed: Related Posts by Category for WordPress.
German Version
Related Posts by Category: Plugin für verwandte Beiträge einer Kategorie
Category as criteria for relevance
The WordPress plugin Related Posts by Category lists similar posts within any post. As a search string the plugin does not use the title of the article nor weighs the content. In fact the category, which was assigned to the post, serves as the source of accordance. The reason for that: Posts from an equivalent category have most of the time identical topics and can therefore be seen as absolute relevant. Is an article assigned to more than one category, all of those categories will be used for the database query. Obviously this leads to more results.
Jump labels
Features
- Post thumbnail integration
- Quick query in only one sql statement
- Quantity of results and further options are adjustable
- Foolproven implementing of this plugin
- WordPress 2.3 required
Mode of operation
After calling the following php function with justified parameters (possible data beneath) out of the template, the activated plugin shows a list of related posts:
<ul>
<?php do_action(
'related_posts_by_category',
array(
'orderby' => 'post_date',
'order' => 'DESC',
'limit' => 5,
'echo' => true,
'before' => '<li>',
'inside' => '» ',
'outside' => '',
'after' => '</li>',
'rel' => 'nofollow',
'type' => 'post',
'image' => array(50, 50),
'message' => 'No matches'
)
) ?>
</ul>
Possible data explained in detail:
- orderby
The parameter orderby comprises the name of the column, by which the displayed data is sorted. In the table discribtion it is defined, which of the columns can be applied. The value “RAND” is responsible for a random generated display. - order
The value ASC for upwards and DESC for downwards affects the sorting direction, but only in connection with orderby. - limit
Limit restricts the quantity of displayed entries. - echo
TRUE shows the result within the ongoing HTML Source code, in another case it brings it as a string back for further processing. - before, inside, outside, after
XHTML tags or just only characters that are inserted before, in or after the generated link.
Format:%before<a>%inside Link %outside</a>%after - rel
The value that is assigned to the function, is used in the REL tag of the anchor, in order to label the links as nofollow or archiv, for example. - type
Is the value empty, also the subpages (static pages) are considered. post as a parameter show only posts, but page shows only pages as output . - message
Standard text as output, if there are no results found. - image
Post Thumbnail output: full, thumbnail, medium, large or array(w, h) with image sizes (w = width, h = height). - hidden
Hidden the post title (title) or thumbnail (image).
Example
A n example with similar articles to this post is found beneath, between the actual post and comments.
Version progress
Version 0.6 dated 08.05.2010:
- Add hook support for the attaching action
Version 0.5 dated 16.12.2009:
- Display the post thumbnail (since WordPress 2.9) or first available image in the post
Version 0.4 dated 08.11.2009:
- Increase the security of the database query
Version 0.3 dated 08.07.2008:
- By chance generated display of results with orderby => ‘RAND’
Version 0.2 dated 07.05.2008:
- post or page as a parameter for type value
Version 0.1 dated 15.02.2008:
- Plugin Related Posts by Category goes online
Installation
- download plugin
- unpack zip archive
- upload the file related_posts.php to the directory ../wp-content/plugins/
- go to the tab Plugins
- activate Plugin Related Posts by Category
- expand single.php about the php call related_posts_by_category(…) (take a look at the example and possible parameters above)
Download
› WordPress Plugin Related Posts by Category ↓
- Format: ZIP
- Version: 0.5
[Der Autor] Sergej Müller ist enthusiastischer Software Engineer mit Schwerpunkten Webentwicklung und WordPress. Seit 2007 programmiert und vertreibt er wpSEO, das weltberühmte und patentierte SEO-Plugin für WordPress-Blogs.
The WordPress plugin wpSLEEP - Easy time control for parts of a post
wpSALE: Mehr verkaufen unter WordPress. Unkompliziert und effizient
42 Kommentare zum Artikel
you rock rock rock !
this looks great. Two questions:
1. Can this be used in the php widget sidebar?
2. Can you specify that you want to show posts from only the current category?
thanks
Hi Jeff.
1. I must first test.
2. If a post appears, it will automatically use the current category.
It seems to work in the PHP exec widget
Is it possible to display image links instead of text links with this plugin?
My website is very image oriented so it would be much handier if I could somehow display the first image of the post instead of a text link.
leverpostei, not yet, I write it for me later.
When I use this with the PHP exec widget, it does not output the properly nested
link
structure. It is missing the and . The plugin is fairly easy to add those in, but I thought I would update you. Thanks.
The form stripped out the email. What I meant to say was that using the php exec widget, the plugin doesn’t add the nested “ul” tags for the list.
I look at this.
Thanks very much for this wonderful plugin. Love the options.
parametres for category id??
Very nice plugin! But I also want to show the post that’s allready showing. Just so that it is in the list. Too bad this only shows related posts and not the post itself.
Is there a way to to this?
hello,
I could not find the file single.php
can you tell me where this file is. I’m using guru-theme
Thanks
great plugin
how do you change the font size and put a title for the related posts?
thanks
Hi, I have a blog about music, therefore my posts are all cateogorized, but they all differ from one another.
I mean, under the category “Jazz” “Pop” “Rock”, all posts talk about jazz, pop, rock,… but about different records and artists.
I would like the plugin to do what its name says: related posts by category, no matter what they talk about. If a person comes to my website using a search engine, chances are that the other post in the same category may interest them as well…
Could this be achieved with this plugin or should I look somewhere else? (I’ve installed it and no related posts show)
Regards and thanks for your time and effort
Alf
How to display the last posts from the parent category. For example:
I have the main category Sports with subcategory: tennis, footbal, basketball, etc
If my last article in category Sports is asigned to subcategory Tennis, then the plugin will show my last 5(or any other number of posts) from Tennis category.
All i want is that the plugin to show my last 5 from the parent category: Sports and not to show my last 5 from tennis.
How to make this?
You can see the plugin in action here: http://www.shtiri.ro
Thanks in advance!
@Tcmo6
I implement your request in the next update.
Thanks man. i am waiting for that.
Will you be adding exclude?, the ability to remove a list of cats would be great.
Great idea – I was just looking for this functionality. I have already added to two websites.
I have tested in a couple of categories, it was working fine. But today, I noticed, it also list posts from categories other than the current one.
The posts that is being listed under a different category looks to have some relation with the current category – either it contains the exact current category keyword(description of the category) as part of the content or as a tag. (Each post only belongs to one category)
I was going to add the plugin to more sites but will wait now if it could be solved. Hope you can have a look to this problem.
Thanks
Related posts by category shown in random order is exactly what I’m looking for my blog. Thanks a lot!! =)
I use my wordpress to build my online store where I sell my hand knit hats (made by me) and I was looking for a plugin that could display a link to all of the items in my shop on each single page article. I easily accomplished this with your plugin simply by adding a new category (made by david) and assigning that to each item in my shop. I now have a convenient list of all items listed on each page thanks to your plugin. Thank you so much for creating it.
Fantastic plug-in, thank you very much!
I just have one query. I am using private posts on my site, do you have any idea on how I would modify the plug-in so that it finds and displays these posts to authorised users? Currently the plug-in doesn’t seem to recognise any private posts. I’ve found the following links which I thought would help, but I’ve still not been able to get it to work with the plug-in…
http://codex.wordpress.org/Function_Reference/wp_count_posts
http://wordpress.org/support/topic/211626
Many thanks!
Great plugin. big thanks to Sergej Müller
Hi,
Can you add one title option to this awesome plugin. for example,
You’d like to see (the title I want)
blah blah blah
How can I do to include thumbnail image for each link ?
Thank you
Yes, in comming version.
Ok, thank you for immediate reply !
Hi,
It works great, i got a lot more pageviews after installed
Great plugin! Thank you so far! :)
My goal is to include only posts that are older than the current, so internal linking would work static. Currently even old articles show links to the newests posts.
Is it possible to configure this? Or is an update in work? I think it would very great if that was possible!
hi–can you use this for displaying posts from categories bound to the current user: i.e how would you factor in a user_id where that is tied to a particulapr post and display only those posts relevant to the current user?
thks
Sam
great plugin
Im trying to add it to the sidebar is it possible ?
i want it to include excerpts & content of the posts
tnx a lot
Hello,
First and foremost this is an excellent idea! I love the concept. I am however not able to get it working! I’d like to have it work in my right hand sidebar and have not certain exactly which code to put. The long list starting with UL or the single line of PHP mentioned above. And in the “single.php” file, I’m not sure where to put it.
Any assistance is appreciated!
Thank you,
Rocky
Super Plugin, vielen Dank dafür. :-)
Gruss
How should I make this plugin active ? I activated is, but it isn´t working…
Please put
<?php new RPBC(array(params)) ?>in your single.php template for display a list of similar posts. See “Mode of operation” below.Hi,
I really like this plugin, it’s the best one for related posts, but is there a way to add also the posts’ date near their titles?
Thanks in advance
@elena
Not yet feasible. Must be first programmed.
I copied the HTML above (
‘post_date’,
‘order’ => ‘DESC’,
‘limit’ => 5,
‘echo’ => true,
‘before’ => ”,
‘inside’ => ‘» ‘,
‘outside’ => ”,
‘after’ => ”,
‘rel’ => ‘nofollow’,
‘type’ => ‘post’,
‘image’ => array(50, 50),
‘message’ => ‘no matches’
)
);
} ?>
into my single posts.php. It does make recent posts show up, but with no title like “Check out these recent posts” and the thumbnail images & text are hard left justified with tiny text and tiny bullet points. How do you add a title, increase the small text, and maybe center the whole list?
into my
Hi Sergej, thanks for this plugin.
My question is : why is my site displaying a double style type?
One is the » and the other is a dark circle.
I hope you don’t mind to check my website, the url is in my comment’s website field
Nevermind I got it work by adding this in css = ul {list-style:none;}
Happy New Year!
works perfectly with my theme ,thnx for this and please make more plugin like these!!
3 Verlinkungen auf den Artikel
› New Related Posts by Category WordPress Plugin | WordPress Hacks
› Ultimate Collection of WordPress Plugins
› Membuat Related Post Wordpress Tanpa Plugin : Blog SEO