Does anyone know how to get "related posts" working in the thematic_postfooter using the functions.php file of a Thematic child theme?
I have tried various related posts plugins and all of them want to insert the data before the postfooter. I assume this is because the plugin's function is being called in the functions.php rather than in the single.php.
I've hacked together a solution for now (posted below). This pulls post related by the category. However, it is not as elegant as I would like it to be. Using one of the available "related posts" plugins would allow for more options and related data without having to rewrite it myself.
// Set the current post's ID equal to a variable to exclude from the query
$currentpost = $post->ID;
// Get post categories and set $cat to first category
$cat = get_the_category(); $cat = $cat[0];
// Set arguments for the get_posts function more options found at wordpress codex
$args = array(
'numberposts' => '10',
'category' => $cat->cat_ID //calls category ID number
) ;
$postrelated .= '<ul>';
global $post;
$myposts = get_posts($args); //gets arguments from array above
foreach($myposts as $post) : //loops through posts
if( $post->ID == $currentpost ) continue;
setup_postdata($post); //sets up posts
$postrelated .= '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
endforeach;
$postrelated .= '</ul>';
Hopefully, this all makes sense and someone else can help. Thanks!