Limit number of comments from get_comments()

I don’t usually work with comment so my suggestion is untested, but I see that get_comments() receives an array of args. Try this: $comments = get_comments(array(“number” => 3)) and instead of your foreach loop: foreach ($comments as $comment):

Make every comment go to the spam folder

I don’t know of a way the default comment status can be changed, but there’s an action ‘comment_post’ that runs after comments are inserted that you could easily hook to set every new comment to have the ‘spam’ status: function set_new_comment_to_spam($commentId) { wp_set_comment_status($commentId, ‘spam’); } add_action(‘comment_post’, ‘set_new_comment_to_spam’, 10, 1); Add that to your functions.php

Send a mail to specific address in a custom field when a new comment is made on a specific post

It sounds like it’s not working because you’re hooking into comment_post, which is when the comment is created If you change the status of the comment, the comment already exists, and therefore no email is generated. There is a comment status change hook: comment_{$old_status}_to_{$new_status}. It fires anytime a comment’s status changes from one specified status … Read more

Review count per product

WooCommerce provides a function for this. You should not need to query the comments and count them: add_shortcode( ‘reviews_count’, function() { // Make sure we’re on a Product. if ( function_exists( ‘is_product’ ) && is_product() ) { // Get a WC_Product object for the current product. $product = wc_get_product( get_queried_object_id() ); // Return the review … Read more