Where are comment ratings stored?

As stated in the comments below the question, Comments don’t have ratings in WordPress I went on and inspected the HTML source for one of my posts and figured out which plugin generated the rating based on the CSS class name. I should have known better. The plugin is Tasty Recipes by WP Tasty. I … Read more

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

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

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