How to make empty comments in WP

If need to show only stars in rating system in woocommerce – the question is : how to show empty comment content, How to make empty comments in WP?

Answer is: Just put this code in your functions.php

add_action('pre_comment_on_post', 'custom_comment');

function custom_comment($post_id) {

    $random = '<code>This is Auto comment with random key: ' . rand(1, 1000000) . '</code>';

    if (empty($_POST['comment'])):
        $_POST['comment'] = $random;

and this in your style.css

.comment_container code {
    display: none;

this is it!




17 thoughts on “How to make empty comments in WP

  1. Have you ever considered writing an e-book or guest authoring on other websites?
    I have a blog based on the same ideas you discuss and would really like to have you share
    some stories/information. I know my viewers would appreciate your work.
    If you are even remotely interested, feel free to send me an email.

  2. Thanks for the marvelous posting! I really enjoyed reading it, you can be a great author.
    I will remember to bookmark your blog and will eventually come back someday.

    I want to encourage one to continue your great writing, have a nice

  3. I’m really enjoying the design and layout of your website.
    It’s a very easy on the eyes which makes it much more pleasant for me to come here and visit more often. Did you hire out a developer to
    create your theme? Great work!

  4. Excellent post. I was checking continuously this
    blog and I’m impressed! Very helpful info
    specifically the last part 🙂 I care for such information a lot.
    I was seeking this particular info for a very long
    time. Thank you and best of luck.

Leave a Reply