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!

  • Filipe

    With this post you solved my problem, thank you ;)

    • backyardowner

      Hello Flipe,

      I’m very glad to hear that this post helped you! Thanks for sharing!

  • Bruno

    Thanks ! It worked for me as well!!!

    • backyardowner

      Hello Bruno!

      Great to hear! Thanks for sharing!

  • JAN

    DUDE!!!!!!!! This post is truly my Savior! I tried so much, and this is the only method that worked. Although, I only had one file that called for that file name, only in comment-template.php. And I didn’t have to do a fresh re-install, just simply renaming the file and replacing the filename. Basically just step 4, and it worked like a charm. DANKE!

    I had to comment to leave you my Thanks, even though I had to take that extra step to verify my email ;)

    • backyardowner

      Great to hear that it helped you man! Really appreciate that you went through all those hassles just to leave a comment.

  • Fabrikio

    hello, many thanks for your help! For me this worked, but what happens with wordpress updates?

    • backyardowner

      Glad to hear it helped you out. It should work without redoing all that again. I have updated several times without any problems.

    • backyardowner

      I take my statement back regarding not redoing everything after WordPress updates. You might need to repeat the steps given in this blog again after each update actually but you shouldn’t loose your content when doing this. The only reason why I haven’t noticed the problem after updates is most probably due to the fact that I have been using Disqus commenting system for a while now.

  • Fabrikio

    Hello! I had to repeat after the WordPress 4.7 updates

    • backyardowner

      Aha ok, thanks for the information! Maybe I haven’t noticed the problem after updates because I have been using the Disqus system for the comments on my website.

  • b4rtman


    • backyardowner

      Hello b4rtman,

      Thanks for sharing!

  • Andrei

    Thank you so much you are a genius bro

    • backyardowner

      Hello Andrei,
      Glad to know that this post helped you bro!