Hi,
I am trying to place on my sidebar an area listing the most commented, i.e. popular, posts, which I was able to do with a basic wpdb query. But I am having the problem of getting the category names for those posts, arising from the obsoleteness of "post_category."
Here is the code I currently have:
global $wpdb ;
$result = $wpdb->get_results ( "SELECT comment_count, ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY comment_count DESC LIMIT 0 , 5" ) ;
foreach ( $result as $post )
{
setup_postdata ( $post ) ;
$postid = $post->ID ;
$title = $post->post_title ;
$category = $post->post_category ;
$commentcount = $post->comment_count ;
echo '<li><a href="' . get_permalink($postid) . '">in ' . $category . ': ' . $title . ' (' . $commentcount . ')</a></li>' ;
}
I know category information is now stored in separate tables. How can I retrieve that information in the same query?
Thanks