Comments Reply Form

Ensure that you have Threaded Comments enabled: go to Dashboard -> Settings -> Discussion and enable the option to thread comments Ensure that your Theme enqueues the comment-reply script. Look for the following, usually in header.php, functions.php, etc.: <?php wp_enqueue_script( ‘comment-reply’ ); ?> Note: this call is usually wrapped in a conditional, such as: <?php … Read more

Why is styling comments so complex?

If you prefer simple template files, you can do that with custom comment callbacks too. Call wp_list_comments() with a custom callback handler: wp_list_comments( array( ‘callback’ => ‘custom_comment_callback’, ‘style’ => ‘ol’ ) ); Now make that callback function very simple: function custom_comment_callback( $comment, $args, $depth ) { include ‘comment-template.php’; } And now you can use comment-template.php … Read more

Display all comments or recent comments per user on author page

your problem is using author_email, you need user_id: i just use similar script. <?php $args = array( ‘user_id’ => get_the_author_meta(‘ID’), ‘number’ => 10, // how many comments to retrieve ‘status’ => ‘approve’ ); $comments = get_comments( $args ); if ( $comments ) { $output.= “<ul>\n”; foreach ( $comments as $c ) { $output.= ‘<li>’; $output.= … Read more

How can I remove the title “leave a reply” in the comment box in twentyeleven?

You can filter the default comment_form arguments (which is what’s causing the “leave a reply”). Just drop this in functions.php or in a plugin file. It would probably be better to put it in a plugin and keep your twenty eleven theme unedited (read: easily updated). <?php add_filter( ‘comment_form_defaults’, ‘wpse33039_form_defaults’ ); function wpse33039_form_defaults( $defaults ) … Read more

Is it possible to show custom comment metadata in the admin panel?

To show the content on individual edit pages you need to add custom meta boxes to the comment edit page. You’ll use the key comment for the $page argument of add_meta_box. <?php add_action( ‘add_meta_boxes_comment’, ‘pmg_comment_tut_add_meta_box’ ); function pmg_comment_tut_add_meta_box() { add_meta_box( ‘pmg-comment-title’, __( ‘Comment Title’ ), ‘pmg_comment_tut_meta_box_cb’, ‘comment’, ‘normal’, ‘high’ ); } function pmg_comment_tut_meta_box_cb( $comment ) … Read more

Disable wordpress comments API

There is much easier way to close standard WordPress comments. Just add add_filter( ‘comments_open’, ‘__return_false’ ); to your functions.php file and comments will be closed.

Why are default comments deprecated?

You shouldn’t copy that file, precisely because it is too bulky. About half of it is implementation of submission form, which was entirely replaced with comment_form() function around that time. So the answer why was it deprecated is roughly: Newer code is more compact Markup belongs in theme For better and more relevant comments.php example … Read more

Comment form validation

Comments processing is done in the file: wp-comments-post.php. You can use the hook pre_comment_on_post to validate the values entered in the comment form fields. function custom_validate_comment_url() { if( !empty( $_POST[‘url’] ) && !preg_match( ‘\b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]’, $_POST[‘url’] ) // do you url validation here (I am not a regex expert) wp_die( __(‘Error: please enter a valid url … Read more

How to remove commenters ability to add hyperlinks to comments?

WP runs so many prettifying filters on this stuff that it’s easy to get lost. Here is what I ended up with: remove_filter(‘comment_text’, ‘make_clickable’, 9); add_filter(‘pre_comment_content’, ‘strip_comment_links’); function strip_comment_links($content) { global $allowedtags; $tags = $allowedtags; unset($tags[‘a’]); $content = addslashes(wp_kses(stripslashes($content), $tags)); return $content; } This scrubs out clearly defined links and removes filter that turns plain … Read more