Related Posts
Filed Under: Plugins
I have been looking around online for a plug-in that would generate related posts for my articles. One where I didn’t have to do anything, but install it and tell the loop where to display it. Well, after many hours of searching I finally found it! The people over at WASABI WP Plugins Wiki did a fine job on this plugin.
Well here are the simple steps:
- Download the latest version.
- Upload the plugin file (related-posts.php) to your /wp-content/plugins/ directory and activate it.
- You will notice a “Related Posts Options” tab under your “Plugins” tab. If this is your first time installing this plugin please click the link for index table setup script at the bottom of the options page. You only need to do this once when you install the plugin for the first time. If automatic setup fails (can happen and may not even be my fault) read step four…
- If automatic creation of a full text index fails. You will have to set it up manually. Don’t worry it’s not hard. Just open your database in phpMySQLadmin and run the following command (cut & paste):
ALTER TABLE `wp_posts` ADD FULLTEXT `post_related` (`post_name` ,`post_content`)
Now, I had to do the fourth step and go into my phpMyAdmin and create that table. Copy exactly what is there, and than just paste it in there and press go. That’s it. Your plugin is installed. Now, you need to tell the loop to call this plugin.
Well, open up whatever file is the file with your loop on it, and than create a div for where you want the related posts to show up. Then copy this php code inside of that div:
<?php related_posts(); ?>
The next thing to do is declare what you want the function to do. Here is the order of what would go inside of the parentheses (it is split up for easier reading):
related_posts($limit, $len, '$before_title', '$after_title', '$before_post', '$after_post', $show_pass_post, $show_excerpt);
Here is what each declaration will do:
- $limit - No. of related entries to display. (Defaut: 5)
- $len - Desired excerpt length (no. of words). (Default: 10)
- $before/after_title - Text to insert before/after the title section.
- $before/after_post - Text to insert before/after the post exceprt section, if displayed.
- $show_pass_post - Toggle show/hide password protected posts. (Default: False)
- $show_excerpt - Toggle show/hide excerpts. (Default: False)
If you do not want to use one of the declarations, or want it to use its default setting, than just skip it. Here is an example:
(5, 10, '< li >‘, ‘< /li >‘, , , false, false);
Thats it! All you have to do is go and style your related posts. Remember that if you use the above, you need to declare that it is an li element, and style it accordingly. That’s it! Go have fun with related posts!




