Sort post by last commented

For this you can use WP_Comment_Query. The query will be $comments_query_args = array( ‘post_type’ => ‘post’, ‘number’ => 5, ‘status’ => ‘approve’ ); $comments_query = new WP_Comment_Query(); $recent_comments = $comments_query->query($comments_query_args);

Conditionally process comments while ignoring replies

Simply check if the comment has a parent before decrementing points. Reading the Codex entry for the get_comment() function, you’ll note that in the manner you use the function you will be returned an object containing keys that correspond to the column names of the wp_comments table. Viewing the wp_comments scehma, note that there is … Read more

Trash a post, send associated comments into the trash bin (change status)

There’s an action called trashed_post_comments that runs right after the comments are set to post-trashed status. You could hook into that: add_action( ‘trashed_post_comments’, ‘wpse134528_really_trash_comments’ ); function wpse134528_really_trash_comments( $post_id ) { $args = array( ‘post_id’ => $post_id, ‘status’ => ‘post-trashed’, ); $comments = get_comments( $args ); foreach( $comments as $comment ) { wp_trash_comment( $comment->comment_id ); } … Read more