WordPress – Blank page redirection from wp-comments-post.php file

Problem Description

If you are getting a blank page after users or you write a comment on your posts and then press the Submit button. Then this post might just be your saviour and save you from further frustration & waste of time.

I was having the same problem as described above and  I was literally tearing my hair off. I had made an extensive search on the website for solutions, some of them included:

  • Re-installing WordPress.
  • Repairing the database.
  • Editing the wp-comments-post-php file using different code examples and tips given on the internet.
  • Turning on debug mode and log file for WordPress

But to my utmost disappointment none of them seemed to work. I wasted many hours on this until I took matters into my own hands and started to take drastic measures.

Problem Source

The drastic measure I took, after wasting a lot of hours editing the wp-comments-post.php, was deleting everything in this file and inserting the following simple php code-snippet:

When I loaded this file using the http://nerdbackyard.com/wp-comments-post.php/, I was still met by a blank page. That is when I realised that there is something wrong with the file name. I created a new php file in the same folder with a different name, copied the same simple code as above and loaded this file in the browser. Viola, I was met with the message Hello World! in the browser window.

My final guess for the source of the problem is that my host company i.e. AwardSpace is blocking files that are named wp-comments.post.php.

Problem Solution

If you think you have a similar problem as described in The problem description section and the source of the problem could be as given in Source of the problem section, then you have come to the right place my friend. Follow the steps outlined below and feel the euphoria spreading into your whole body.

  1. Connect to your WordPress installation through a FTP client such as FileZilla and delete all the files and folders excluding your wp-content folder, wp-config.php and .htaccess files.
  2. Download a fresh version of WordPress to your local hard drive.
  3. Unzip the file and rename the wp-comments-post.php to something else (for example newname.php) in the unzipped folder.
  4. Once this is done, you need to find reference to wp-comments-post.php in every single .php file located in the WordPress folder and replace it with the newname.php. I’m on a Mac so I used spotlight search, which searches the content of files as well. The files which I found contained a reference to wp-comments-post.php are:
    1. comments.php, which is located under wp-includes/theme-compat/
    2. comments-popup.php which is located under wp-includes/theme-compat/
    3. comment-template.php which is located under wp-includes/
  5. Once this is done, you are ready to upload the wordpress folder contents to your website using the FTP client.

After this change, the commenting should work fine and newname.php file should now redirect you back to the the comment you just created.

If  you found this post useful, please share and leave a comment, thank you!