How to enable comments for pending and draft posts?

The following enables the default meta box for draft and pending posts (in the portfolio post_type): add_action( ‘admin_init’, ‘wpse_74018_enable_draft_comments’ ); /** * Add Comments Meta Box if CPT is ‘draft’ or ‘pending’ */ function wpse_74018_enable_draft_comments() { if( isset( $_GET[‘post’] ) ) { $post_id = absint( $_GET[‘post’] ); $post = get_post( $post_id ); if ( ‘draft’ … Read more

How to wrap submit button of comment form with div

We can use comment_form function’s submit_button parameter to change submit button HTML. Default HTML for submit_button is <input name=”%1$s” type=”submit” id=”%2$s” class=”%3$s” value=”%4$s” /> You can change your code like this. $comments_args = array( …. ‘submit_button’ => ‘<div class=”form-group”> <input name=”%1$s” type=”submit” id=”%2$s” class=”%3$s” value=”%4$s” /> </div>’ …. ); Update: Regarding %1$s , %2$s and … Read more

How to add a class to the comment submit button?

If you check out the source of the function comment_form(), you’ll see it doesn’t even print a class on the input; <input name=”submit” type=”submit” id=”<?php echo esc_attr( $args[‘id_submit’] ); ?>” value=”<?php echo esc_attr( $args[‘label_submit’] ); ?>” /> I’m guessing you need to add a class for styling? Why not modify your CSS to just; input.submit, … Read more

Importing old Disqus comments into WordPress

Without having a sample xml file, it’s impossible to try to debug that plugin and see where it is failing. Tried to search if some innocent soul left a file hanging on the internets, but nope. But one can see what others are saying: The nightmare that is Disqus export, and import into WordPress. September … Read more

Is it possible to filter comments in a post so a user can only see the comments they have written?

Assuming your comment authors are intended to be registered users, the easiest way is probably to use a pre_get_comments action hook to modify the WP_Comment_Query object‘s user_id query var such that the query only returns comments from the current user: function wpse262203_restrict_comment_views( $comments_query ) { // Don’t interfere with comment results in the dashboard if( … Read more

Stop WordPress redirecting comment-page-1 to the post page?

Great question! WordPress assigns your comment page number to the query var ‘cpage’ which gets set when your URL has /comment-page-1/ at the end. So your culprit is in the redirect_canonical() function, line 192 of /wp-includes/canoncial.php. if ( get_query_var(‘paged’) || is_feed() || get_query_var(‘cpage’) ) { Since the redirect_canonical() function gets set as an action what … Read more

Removing the “Website” Field from Comments and Replies?

Create a file in wp-content/plugins/ with this code: <?php /* Plugin Name: Get Rid of Comment Websites */ function my_custom_comment_fields( $fields ){ if(isset($fields[‘url’])) unset($fields[‘url’]); return $fields; } add_filter( ‘comment_form_default_fields’, ‘my_custom_comment_fields’ ); Normally, I’d say put it into your theme’s functions.php file, but I wouldn’t recommend doing that for a theme that could update like Twenty … Read more

Change HTML Produced by wp_list_comments()

Here are some options on how we can override the native layout for each comment: Approach #1 – Overriding start_el() with a custom walker Let’s define our custom wpse comment format: // Arguments for wp_list_comments() $args = [ ‘style’ => ‘ol’, ‘format’ => ‘html5’, ‘short_ping’ => true, ]; // Use our custom walker if it’s … Read more