fiunchinho
Forum Replies Created
-
Forum: Plugins
In reply to: Where is $comments array created? What file, what function?It looks like the only way around is to modify the SQL statement.
For now, Im using this in comment-template.php:
// Choose how many comments you want to take. $limit = 1000; // The actual query. $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) AND comment_ID > ((SELECT MAX(comment_ID) FROM $wpdb->comments) - $limit) ORDER BY comment_date_gmt", $post->ID, $user_ID));
Using this, it will only take the latest 1000 comments. So if you have pagination activated, it will work for those 1000 comments. Assuming that comments older than the latest 1000 comments are “useless”, this would do the trick.
Anyway, there should be a better option.
Forum: Plugins
In reply to: Where is $comments array created? What file, what function?That would fix it for now, but what if the comments keep coming?
The point is that it shouldnt take ALL the comments if you are showing the comments with pagination. Why do I need it?
Any other ideas?
Forum: Plugins
In reply to: Where is $comments array created? What file, what function?I added LIMIT 200 at the end of
if ( $user_ID) { $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt LIMIT 200", $post->ID, $user_ID));
but it doesnt solve the problem, because now it’s like the post has JUST 200 comments, so it shows no pages or navigation. It just shows the first 200 comments.
I need help plz
Forum: Plugins
In reply to: Where is $comments array created? What file, what function?KnowingArt_com , I have the same problem.
I tried your hack and it didnt work for me. It’s like it doesnt use get_comments at all. I tried adding die(“wtf”); in the very first line of get_comments() and the function works normally. I dont see any “wtf”. It’s not using get_comments.
So I guess it’s not going through the “else if”, but the others, that are using $wpdb->get_results():
/** @todo Use API instead of SELECTs. */ if ( $user_ID) { $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, $user_ID)); } else if ( empty($comment_author) ) { $comments = get_comments( array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC', 'number' => '5') ); } else { $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode($comment_author,ENT_QUOTES), $comment_author_email)); }
Any suggestions?