What are the current recommended best-practices for comments.php?

You really don’t need much. A headline with id=comments <h2 id=”comments”><?php comments_number(); ?></h2> This will be the target for comments_link() in the article loop. Links for paginated comments. Usually, I put these links into a function and call the function above and below the comments list: class TTT_Template { function comment_pager() { if ( get_comment_pages_count() … Read more

How is comment spam received without a comments form?

You don’t need a form to submit a comment to the wp-comments-post.php file, or to send a pingback or trackback. Spammers don’t use forms, they simply send their spam directly. Removing the form doesn’t “turn off” comments. To do that, go to the Posts screen, and use the Quick Edit to actually disable comments and … Read more

Add placeholder attribute to comment form fields

You should filter ‘comment_form_default_fields’ to add the placeholder attribute. Sample code add_filter( ‘comment_form_default_fields’, ‘wpse_62742_comment_placeholders’ ); /** * Change default fields, add placeholder and change type attributes. * * @param array $fields * @return array */ function wpse_62742_comment_placeholders( $fields ) { $fields[‘author’] = str_replace( ‘<input’, ‘<input placeholder=”‘ /* Replace ‘theme_text_domain’ with your theme’s text domain. * … Read more

Show content only if member left a comment

Check if the user has left a comment // the user may have commented on *any* post define( ‘CHECK_GLOBAL_FOR_COMMENTS’, TRUE ); // // some more code // function memberviparea( $atts, $content = null ) { $post_id = 0; // if the user have to left a comment explicit on this post, get the post ID … Read more

Facebook comments box on front page

Fast ‘n’ Hacky The problem can be solved by changing line 319 in facebook.php to the following: if (is_home()) { This way, the front page is not treated as a home page but as a regular page, for which the facebook feature settings can be applied (and will be handled correctly). More Elegant/Complex Here is … Read more

get comments and get posts in loop

get_comments accepts an array of arguments, you are passing an integer. If you want to retrieve all comments for a post use: get_comments( array(‘post_id’ => $post->ID, ‘status’ => ‘approve’) ); To get an already formatted comment list, is easier use the wp_list_comments() function, instead of another foreach cycle (code from codex): echo ‘<ol class=”commentlist”>’; //Gather … Read more