0
votes

In my WordPress site I am showing all comments of each post in comments.php file using this code:

wp_list_comments( array(    
    'style'         =>  '<div>',
    'per_page'      =>  10,
    'avatar_size'   =>  50,
    'callback'      =>  'mytheme_comment',
    'type'          =>  'comment',
    'avatar_size'   =>  100,
));

Now I want to hide all comment using a hook in my custom plugin p age with following code:

add_filter( 'comments_array', '__return_empty_array' );

But it's doesn't hide or remove the all comment list, how can I do this?

And is there any hook available in WordPress that I can add some text or html content before the comment list and form ?

Image for better understanding:

enter image description here

Update:

For example, I just disabled the full comment system. So that comment area is blank but I want to show something with any hook. Is there any hook for that?

1
Okay, I understand :(Shibbir

1 Answers

0
votes

Add Custom Text Before Comment Form

Put the code in functions.php file,

function wpbeginner_comment_text_before($arg) {
    $arg['comment_notes_before'] = "<p class='comment-policy'>We are glad you have chosen to leave a comment. Please keep in mind that comments are moderated according to our <a href='http://www.example.com/comment-policy-page/'>comment policy</a>.</p>";
    return $arg;
}
  
add_filter('comment_form_defaults', 'wpbeginner_comment_text_before');

The sample CSS we used:

p.comment-policy {
    border: 1px solid #ffd499;
    background-color: #fff4e5;
    border-radius: 5px;
    padding: 10px;
    margin: 10px 0px 10px 0px;
    font-size: small;
    font-style: italic;
}

Add Custom Text After Comment Form

Put the code in functions.php file,

function wpbeginner_comment_text_after($arg) {
    $arg['comment_notes_after'] = "<p class='comment-policy'>We are glad you have chosen to leave a comment. Please keep in mind that comments are moderated according to our <a href='http://www.example.com/comment-policy-page/'>comment policy</a>.</p>";
    return $arg;
}
  
add_filter('comment_form_defaults', 'wpbeginner_comment_text_after');

Thanks!!