A simple 'related posts' plugin that lets you select related posts manually instead of automatically generating the list.
Tested on WordPress 2.9 - 3.3
Websites:
A simple 'related posts' plugin that lets you select related posts manually instead of automatically generating the list. Supports any post types in WordPress, including custom ones.
Features:
- Add related posts to your blog posts, pages etc.
- Choose from posts, pages or any other post type
- Support for custom post types
- Re-order related posts via drag and drop
- Custom markup possible, or simply use the default output
I wrote the plugin because I wanted to have the option to add related posts to each blog post using a simple but functional plugin without a lot of junk. Unlike other 'related posts' plugins that use algorithms to automatically generate a list of posts, I wanted to be able to select the related posts myself.
The plugin targets small and medium sized blogs. On blogs with lots of posts (500+) it might not be very comfortable to choose the posts via select box.
You can contribute improvements to this plugin by forking it and submit a pull request.
To display the related posts, simply add the following line in your template, inside the WordPress loop.
<?php echo $related->show(get_the_ID()); ?>
to your template, inside the Wordpress loop. For advanced options, see the installation docs.
Use the plugin installer built into Wordpress to search for the plugin. Wordpress will then download and install it for you.
-
Make sure the files are within a folder.
-
Copy the whole folder inside the wp-content/plugins/ folder.
-
In the backend, activate the plugin. You can now select related posts when you create or edit blog posts, pages etc.
The related posts are displayed by adding
<?php echo $related->show($post_id); ?>
to your template. Replace $post_id
with a post ID. If you call it within the Wordpress loop, you can use
<?php echo $related->show(get_the_ID()); ?>
You have the option of either outputting a pre-formatted list or returning a PHP array of related posts to customise the markup yourself.
<?php echo $related->show(get_the_ID()); ?>
This can be called within the Wordpress loop. It will output a <ul>
list with links.
<?php $rel = $related->show(get_the_ID(), true); ?>
With the second argument set to true, it will return an array of post objects. Use it to generate your own custom markup. Here is an example:
<?php
$rel = $related->show(get_the_ID(), true);
// Display the title of each related post
foreach ($rel as $r) :
echo $r->post_title . '<br />';
endforeach;
?>
People who want to list 'related posts' in their blog posts or pages, and want to choose the related posts themselves, instead of having a list generated automatically like other plugins do, using weird algorithms that often create comical results.
Data is stored in the existing postmeta table in the WordPress database. No additional tables are created.
As many as you like, there's no limit.
4. Wordpress version 2.9 is listed as minimum required version. Any chance it will work with earlier versions?
There's a chance it will work with earlier versions, but I haven't tested it.
5. I have 500+ posts on my blog and selecting the posts with the one select box isn't very comfortable, lots of scrolling.
That's true, it isn't ideal for large blogs. This might get improved in future releases, feel free to submit ideas.
Yes, I don't know what the problem is. It's only in WordPress 2.9. Just delete the plugin directory manually from wp-content/plugins.
With version 1.1, all data remains in the database when the plugin files are deleted through the plugins page in WordPress. So if you accidentally delete the plugin, or if you decide to install it again later, your data should still be there.
Not very actively, mostly because my focus is on Ruby development, so my interest in WordPress/PHP is limited. However I get quite a few emails from people who enjoy using the plugin, so if there are any major issues I will look into it.
If you're a developer you are encouraged to submit improvements. Just fork it and submit changes. Every now and then I might find time to incorporate improvements and push out a new release.
- Minor rewrites that may prevent interference with other plugins
- Bugfix: related posts are now correctly saved (deleted) when all related posts are removed from the current post
- Feature: all post types in WordPress are now supported (including custom ones)
- Improvement: select box now sorts posts by title and displays post type
- Improvement: current post is now excluded from the list of posts
- Improvement: data now remains stored in database when plugin is deleted, to avoid accidental loss of data
- Improvement: general code quality improvements
- Initial release. No known issues.
Either let WordPress do the upgrade or just overwrite the files.