Related Posts Plugin Update
I have just finished updating the plugin I use to display links to related posts when a single post is displayed. The old version only permitted links to related posts to be displayed below the comments section - a placement somewhat too inconspicuous.
The new version is hooked into the Wordpress loop differently, which allow links to related posts to be placed pretty much anywhere.
Because I already have the plugin installed (and have appropriate database tables in place), I needed to run a small upgrade script - 'upgrade_related.php'. The script did not run straight off the bat because it references some variables, which are not declared anywhere. I had to add the following declarations at the bottom of 'wp-config.php' in the root folder of the Wordpress installation.
$loginsql = DB_USER;
$passsql = DB_PASSWORD;
$base = DB_NAME;
Next, I added some code to 'single.php' - just above the post meta information - to actually display the links to related posts:
If you click a permalink to one of my posts, you will see the links to related posts at the end of the post text, just above the meta information of the post.
***** UPDATE *****
It appears that the 'Related Posts' plugin graps everything from the database, including unpublished posts.
***** UPDATE #1 *****
Fixed the 'get-everything' issue, by hacking the SQL statement in 'related.php' to only fetch published posts:
".$table_prefix."posts WHERE post_status = 'publish' AND MATCH (post_title,post_content) AGAINST ('".$stuff."') AND ID <> ".$post->ID." LIMIT 0,".$max_related;
This excludes drafts, private and static (pages) posts.
If you enjoyed this post, make sure you subscribe to my RSS feed!