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

How do I delete all comments from a specific old blog post?

Alternative for people reading this with a fear for SQL…………… (or finding this via Google after Januari 2011): Wait for this action until 3.1 comes out, then go to a post, check all comments and bulk “move to trash” 🙂 (it should come out any day now) (http://wordpress.org/about/roadmap/) (or download 3.1 RC3 from http://wordpress.org/download/release-archive/) Example: … Read more

Disable comments on all posts/pages

The check if comments are enabled is performed by comments_open() function. You can make it always return false via a filter with something like this: add_filter(‘comments_open’, ‘__return_false’); Other way would be to make comments available to only registered users (that is if you don’t have open registration) in Settings > Discussion.

comment_post_ID 0 (cannot remove from dashboard)

I’m sorry can’t comment here but i’ll try to help. wp_handle_comment_submission function handing comments posting contains exact check for post_id: $post = get_post( $comment_post_ID ); if ( empty( $post->comment_status ) ) { … return error_happened; } i.e. (1) it passes through , or (2) comment was added other than default way of posting comments. For … Read more

How to get comments by post ID?

You can use get_comments. Function Reference/get comments $args = array(‘cat’ => ‘home’,’post_type’ => ‘post’)); $post_obj = new WP_Query($args); while($post_obj->have_posts() ) : $post_obj->the_post(); //display comments $comments = get_comments(array( ‘post_id’ => $post->ID, ‘number’ => ‘2’ )); foreach($comments as $comment) { //format comments } endwhile;