16. Oktober 2008 / Closed
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 ...
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.9.1 vom 06.06.2011:
- Bugfix for article titles with a number at the beginning
Version 0.8 dated 15.12.2010:
- Exclusion of desired categories
Version 0.7 dated 16.11.2010:
- Add support for the default thumb image
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.9.1
Sergej Müller ist enthusiastischer Software Engineer mit Schwerpunkten Webentwicklung, Apps und WordPress. Seit 2007 programmiert und vertreibt er wpSEO, das zugkräftige SEO-Plugin für WordPress-Blogs.