How to tweak comment fields properly from functions.php

You are redeclaring the variable $fields after you define the email key – this basically removes all previous values – instead you need to add a new key for comment_field, for example: // retain code before.. $fields[‘author’] = $author_field; $fields[’email’] = $email_field; $fields[‘comment_field’] = sprintf( ‘<p class=”comment-form-comment”><label for=”comment”>%s</label><textarea id=”comment” name=”comment” cols=”45″ rows=”8″ maxlength=”65525″ required=”required”></textarea></p>’, __( … Read more

How to display custom comment fields onto any page

Just in case others are stumped with trying to learn how to reveal submitted comments onto a comments page (or any page for this matter), a good starting point to investigate is using the WordPress function wp_list_comments() There are examples provided on that resource page to get things going in a healthy direction. I would … Read more

Add comment_id on Comments page within wp-admin

Is possible to include a column for comment_id? Yes, and there are two hooks that you’d want to use: manage_edit-comments_columns — use this hook to add custom columns to the comments list table, e.g. the custom comment ID column. manage_comments_custom_column — use this hook to display (echo) the content for a custom column added via … Read more

If x comments in a post move post to category y

You could use the wp_insert_comment action to detect when new comments are added to a post. Then on your action callback, you’d the post’s comment count with get_comments_number(), and change post categories with wp_set_object_terms(). Something along these lines, add_filter( ‘wp_insert_comment’, function($id, $comment) { if ( (int) $comment->comment_approved ) { $post_id = (int) $comment->comment_post_ID; $post_comment_count = … Read more

Help with comments.php

This is not possible using the standard comment form. Comments in WordPress are built around post IDs, and are coded with this assumption down to the foundations. Even post statuses that can receive comments are hardcoded at multiple levels. The comment form itself knows where to go afterwards via the comment_post_ID input. You will not … Read more

I need help using pre_get_comments to limit comments in the comments admin screen

Update In response to the new code in the updated question, you could actually use $wpdb->get_col() with a single SQL command via a JOIN clause, like so: $query = “SELECT c.comment_ID FROM $wpdb->comments c JOIN $wpdb->posts p ON p.ID = c.comment_post_ID WHERE c.user_id = $user_ID OR p.post_author = $user_ID”; $comment_ids = $wpdb->get_col( $query ); However, … Read more

Which hook do I use to edit pending comment count on wordpress dashboard?

You can manually adjust this number using the following method. function adjust_wp_comments_count( $original_counts ) { $counts = new \stdClass(); $counts->moderated = 99; return $counts; } add_filter( ‘wp_count_comments’, ‘adjust_wp_comments_count’, 100, 1 ); The line: $counts->moderated = 99 is what you will need to adjust if you want to set it to a particular value or calculation … Read more

Use of comment_reply_link_args filter

You mean, something like this? add_filter( ‘comment_reply_link_args’, ‘change_author_title’, 10, 2 ); function change_author_title( $args, $comment ) { $args[‘reply_to_text’] = ‘Reply to ‘ . get_comment_author( $comment ); return $args; } Explanation: I changed the function declaration so that it accepts the second parameter ($comment) which is the comment object (a WP_Comment instance), then I simply call … Read more