@Dianuj solved my issue a week ago, when I asked how I can get a recent comment
above a post
. That all worked very well, but yesterday, when I tested it, I saw a little issue, which I not want on my Wordpress
site. Let me explain it to you...
If someone makes a comment on a post that has none comments before you comment, then the function on this page How to get most recent commented post above new submitted post in Wordpress? will work flawlessly. I thank Dianuj for making my life easier.
The problem starts when a user makes a comment on a post that ALREADY has a comment in it. So for instance, you make the second comment on a post. In that case, the post title won't go up and show 'his' face on the page. That is the big problem and I hope someone can help me out with the snippets that are on this link How to get most recent commented post above new submitted post in Wordpress?
PS: for the lazy ones, here it goes -->
<?php
global $wpdb;
$results = $wpdb->get_results(" SELECT p.*,
(CASE WHEN c.comment_date IS NULL THEN p.`post_date` ELSE c.comment_date END) order_column
FROM `wp_posts` p
LEFT JOIN `wp_comments` c ON (p.ID = c.`comment_post_ID` ) WHERE p.post_type='post' AND p.post_status='publish'
GROUP BY p.ID
ORDER BY order_column DESC");
?>