How to get the 5 most recent comments and each comment 5 most recent replies (children)

To list the most recent (5) comments you can use this code : $sql = “SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,50) // NUMBER OF CHARACTERS AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = ‘1’ AND comment_type=”” AND post_password = ” ORDER BY … Read more

Change author, disable comments, enable trackbacks for all items in library

You have to run SQL query to do this. Put this code into your functions.php once, run your website and then delete it. global $wpdb; $author = 1; $comment_status=”closed”; $ping_status=”open”; $query = sprintf( ‘UPDATE %sposts SET `author` = %d, `comment_status` = %s, `ping_status` = %s’, $wpdb->prefix, $author, $comment_status, $ping_status ); $wpdb->query($query); Or run it directly … Read more

Comments pagination on author page

Make sure you’ve set the paged parameter in your query, below is shown how to do that. <?php $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; $args = array( ‘posts_per_page’ => 3, ‘paged’ => $paged ); $the_query = new WP_Query( $args ); ?> For more information about pagination have a … Read more

What is wrong with this? [closed]

The error is in the syntax; there’s a semicolon after the if condition. Try this: <?php $page_comment = get_query_var(‘cpage’); if ($page_comment > 0): ?> test <?php endif; ?> Alternative PHP syntax: <?php $page_comment = get_query_var(‘cpage’); if ($page_comment > 0){ ?> test <?php } ?>

Showing different images depending on user role

What’s the variable $user_info in you code? Probably you mean $commentator_info? If yes, this is certainly the error. You are trying to extract wp_capabilities (?) from a non-initialized variable ($user_info). Try this: <?php $comment_id = get_comment_ID(); $comment_data = get_comment($comment_id); $commentator_id = $comment_data->user_id; $commentator_info = get_userdata($commentator_id); // get_userdata, with the user ID specified, returns a WP_User … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)