php - Comments Not Posting on Wordpress - Blank Page


I am working on a theme (, which I've done before, but if you try to post a comment, you will be redirected to a blank page. This also happens on the other WP themes such as twentysixteen. Here is the code I have on wp-comments-post.php:

 * Handles Comment Post to WordPress and prevents duplicate comment posting.
 * @package WordPress

    $protocol = $_SERVER['SERVER_PROTOCOL'];
    if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) {
        $protocol = 'HTTP/1.0';

    header('Allow: POST');
    header("$protocol 405 Method Not Allowed");
    header('Content-Type: text/plain');

/** Sets up the WordPress Environment. */
require( dirname(__FILE__) . '/wp-load.php' );


$comment = wp_handle_comment_submission( wp_unslash( $_POST ) );
if ( is_wp_error( $comment ) ) {
    $data = intval( $comment->get_error_data() );
    if ( ! empty( $data ) ) {
        wp_die( '<p>' . $comment->get_error_message() . '</p>', __( 'Comment Submission Failure' ), array( 'response' => $data, 'back_link' => true ) );
    } else {

$user = wp_get_current_user();

 * Perform other actions when comment cookies are set.
 * @since 3.4.0
 * @param WP_Comment $comment Comment object.
 * @param WP_User    $user    User object. The user may not exist.
do_action( 'set_comment_cookies', $comment, $user );

$location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : 
$_POST['redirect_to'] . '#comment-' . $comment->comment_ID;

 * Filters the location URI to send the commenter after posting.
 * @since 2.0.5
 * @param string     $location The 'redirect_to' URI sent via $_POST.
 * @param WP_Comment $comment  Comment object.
$location = apply_filters( 'comment_post_redirect', $location, $comment );

wp_safe_redirect( $location );

I don't know why this isn't working since it's straight from WP, and other people online had this error because their file was blank, which is not my case. And all of this code looks to be in order. My MySQL version is 5.7 so that shouldn't be the issue, but at this point, I don't even know what's wrong anymore - the code, the installation, my hosting. Any help would be greatly appreciated.

Update: My host advertises full blog, comment and discussion board functionality but I contacted them and they were like, "not really." Apparently they don't support comments or email sending. What a waste. Thanks for everyone's help!




When you look your problem page with inspect manager, you can see that your problem is a 410 code error. 410 error image

410 Gone

Indicates that the resource requested is no longer available at the server and will not be available again.

This error can occur in several ways.

Here it's the list of somes checkpoint to help you to find the problem:

1. Enable debugging in wp-config.php

     // Enable WP_DEBUG mode
     define( 'WP_DEBUG', true );
     // Enable Debug logging to the /wp-content/debug.log file
     define( 'WP_DEBUG_LOG', true );

     // Enable display of errors and warnings 
     define( 'WP_DEBUG_DISPLAY', true );
     @ini_set( 'display_errors', 1 );

And test to know if your error appear. You'll be able to fix it quickly.

2. Reset permalink

Don't know why but, sometimes, Wordpress have some weird error du to a old permalink.

I suggest you to

  • Going toSettings -> Permalinks
  • Switch permalink setting,
  • Save,
  • Replace it to your current configuration,
  • save it again.

3. Deactivating all plugins.

if its works, activate plugin one by one to be able to detect which one create this error.

4. Refresh your .htaccess

place the basic wordpress.htaccess. Sometimes, some plugins change rules from your.htaccess and provoke many redirections error.

5. Switch your theme for a default theme without modification

It help you to know if a custom rules in your theme create this error.

6. Re-upload the wp-admin and wp-includes from fresh install

7. Reset folders write/read permissions

you can read Changing File permissions in Wordpress to help you to know what you should change and what it should do.

8. ULTIMATELY, Create a fresh install of Wordpress

People are also looking for solutions to the problem: php - Using CodeIgniter framework. How to get_where but limit the results to the past 12 hours?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.