Blank Pages When Posting Comments in WordPress?
I just resolved a problem on one of my WordPress based blogs where anytime a person posted a comment (logged in or not), they got a blank page. I tried all sorts of stuff to fix it. Turned off all the plugins, changed themes, you name it. I quickly discovered that when the comment form was submitted, none of the form variables were available in the wp-comments-post.php script. When this happens, the post can’t be queried from the DB and you fail on Line 11 (comment_id_not_found). A quick bit of debug code and I found NONE of the form variables were in $_POST. Not good.
I figured maybe something was in the theme headers, etc so I created a simple form with a couple variables that would post to wp-comment-post.php and it worked. Hmm. So I tried the other angle and created a comment post test script that dump the form variables and called it from my theme form file. The variables disappeared. Any theme, the variables vanished in my test script.
This had me totally confused. Why couldn’t I get basic form data into my form. Google returned a variety of ideas, but none that worked. Finally, I stumbled across a ticket for WordPress searching for ‘Blank Page on comments’ and someone had the same problem I did and for the same reason. It’s a doozy.
I’m one of those people who find the ‘www’ in URLs redundant. All my sites support them both, but from an SEO point of view, I’ve started ensuring www.mydomain.com permanently redirects to mydomain.com. When I setup this blog a few years ago, I had put in ‘www.baptiste.us’ in the blog configuration. A few months ago, I added a permanent redirect for www.baptiste.us to always go to baptiste.us. Everything worked as far as I could tell and since I don’t comment on my blog except to respond to new comments, well… That redirect and the blog settings BROKE the comments and I didn’t realize it for quite a while (I just figured nobody had anything to say
). Here’s why.
In WordPress theme comment files, the form ‘action’ variable includes the site url in front of wp-comments-post.php. So for my comment form, the action was set to http://www.baptiste.us/wp-comments-post.php, regardless of the theme I used. The problem is, the Permanent Redirect from www.baptiste.us to baptiste.us WIPES OUT the form variables, even though everything else seems to work. Silently. Now this may be due to session conflicts, etc, I’m not 100% sure.
But the solution was easy. I took out the ‘www.’ in my blog’s config so comment posts went to the ‘baptiste.us’ domain right away instead of www.baptiste.us and comments started working again.
Moral of the story - if you have a permanent redirect setup for your WordPress blog, be sure the desired domain is the domain set in the WordPress config. If you want everyone to end up at www.mydomain.com, you better have the ‘www’ in your WordPress config. If you want the www to always go away, make sure it’s not in your config either. Hopefully this post saves someone else the time and aggravation if they stumble into this trap.
So 3 days and nights of debugging on and off and all it took was updating two config variables in WordPress. Problem solved
ADDING: Beware of WordPress 2.3’s new Canonical URL feature. It’s a great feature, long overdue, but if you have redirects in .htaccess, you can possibly create a redirect loop. Lots of info on this feature can be found at Mark on WordPress.
February 18th, 2007 at 4:55 pm
THANKYOU!!!
I struggled with this myself, and your solution totally nailed it.
Cheers!
February 24th, 2007 at 6:25 pm
Thank you so much. You turned me down the right path. My provider blocks port 80, and I use no-ip with port redirect to update my changing address. Apparently, the ‘redirect’ caused WP to act the same way. To fix the problem I removed the port 8080 redirect and added the port to the URL in the options. Thanks again.
March 17th, 2007 at 8:25 am
Worked like a charm.
March 18th, 2007 at 12:12 am
nice nice work, man. when i read the line “I’m one of those people who find the ‘www’ in URLs redundant.” i knew EXACTLY what caused my problem. after finding the solution, i went into my config screens, deleted the ‘www’ and now all is golden.
May 1st, 2007 at 10:55 am
Thank you, it worked for me too!
May 24th, 2007 at 12:28 pm
Thanks it works perfect!
May 25th, 2007 at 6:45 am
Thanks bro!! I’m so glad you took the time to write this post.
June 2nd, 2007 at 6:21 pm
Wow. Thanks so much for that fix!!
June 12th, 2007 at 3:56 am
[...] Das war die Lösung. Danke dafür, [...]
June 25th, 2007 at 8:26 pm
Thanks for the help. You just saved me a huge headache in a 30 second Google search and reading your post!
Tom
July 3rd, 2007 at 3:01 pm
Thanks.. easy fix once the problem is figured out surprised this isn’t in the wordpress support as it seems pretty common
August 22nd, 2007 at 5:02 pm
Thank you so much. I would have *never* thought to do this kind of fix… But it worked like a charm
Uhhh, SEO can sometimes do evil things to ya..
September 2nd, 2007 at 7:01 pm
Damn. It doesn’t work for me. I did have a redirect for all traffic to http://www.blackjackskanz.com/index.php which I removed but no avail. I posted in a thread at Wordpress but I am at a loss.
Site
http://www.blackjackskanz.com/
Forum Post
http://wordpress.org/support/topic/87090?replies=29#post-610491
September 3rd, 2007 at 8:53 am
That’s fine for me! Just need to make the invert thinkhing!
Thanks for the brillinat aswer! I’ve opened a topic for myself on WPress foruns about this. As your aswer solves my question I’ll close it with a link to this page, if you don’t mind.
September 6th, 2007 at 3:57 pm
Ugh. what headache this issue has caused me — thank you for providing some isight into this.
September 12th, 2007 at 1:06 am
Let me add my thanks. Stumbled across this web page via a Google search on “wp-comments-post.php fails”. You saved me a lot of time–and I had already spent a lot of time on this!
Thank again,
Curt
September 18th, 2007 at 1:22 pm
Thank you for this post. It solved the same problem I had.
September 19th, 2007 at 9:38 pm
[...] blog. They work now so you can write as many comments as you’d like. This is how I fixed it: http://plugins.baptiste.us/wordpress/blank-pages-when-posting-comments-in-wordpress/ What a tricky [...]
September 25th, 2007 at 12:40 pm
I don’t get it. Sometimes I get a blank page after attempting a test comment post other times nothing. In my logs I see thousands of 404s for the wp-comments-post.php page from my guestbook…
I’m set up with http://www. in place everywhere it should be, so it’s not that…
db
September 25th, 2007 at 2:06 pm
Wow, you just saved me another 2 hours of searching. Thank you. I owe you a beer or something
September 25th, 2007 at 3:20 pm
David - the 404s are spammers trying to spam your site. But intermittent blank pages seems odd. Its usually all or nothing. Anything in your error_log when you get a blank page? Sounds like some type of PHP problem.
October 22nd, 2007 at 12:49 pm
I found you with Google search. Thank you, now I have no blank page
December 4th, 2007 at 7:48 am
I have the same problem with a blog installed on a vpn network, where people access it via an ip… any thoughts on that?
December 4th, 2007 at 9:00 am
If I had to guess, it’s a similar problem where they are using some type of redirect to get you to the final site. That’s the core problem - redirecting on a form submit often wipes out the form data.
May 5th, 2008 at 10:01 pm
Hi,
I had the same problem, though the above solution wasn’t relevant. However, for anyone it helps: I managed to fix it by basically unchecking all boxes in options>discussion, and removing the lists of spam words to check, saving, and then replacing. I suspect there was a problem somewhere with the lists of spam words.
Exactly what the problem was I don’t know, but it seems to be fixed now . . .
August 19th, 2008 at 6:22 am
hi
i am facing same problem can any body give me any other weblink
where i can search out errors
thanks
October 29th, 2008 at 11:08 am
it worked for me thaks saving my time
January 1st, 2009 at 10:28 am
[...] Blank Pages When Posting Comments in WordPress? [...]
January 26th, 2009 at 2:30 pm
Yeah, I just figured this out too. Mine was caused due to the ‘home’ and ’siteurl’ option in the database being set to http:// while my blog is under ssl, so https:// was needed. I used a MySQL query something like
UPDATE wp_options SET option_value = replace(option_value, 'http://', 'https://') WHERE option_name = 'home' OR option_name = 'siteurl';
Worked!
April 22nd, 2009 at 1:00 pm
“I am posting this message the second time coz the first time it said..that you message has been flagged as spam and into moderation”
Now the second time i am removing my website url from the website field and i am pretty much sure that the message would show up. I don’t know what is spam in this message..you see it for your self
There is no doubt that Akismet Marks Valid Comments As SPAM even googling it would show hundreds of bloggers being frustrated because of it. I spent my entire day today googling to check results for..
1) my site wrongly spammed by aksimet
2) my site wrongly spammed by wordpress
3) my site wrongly flagged by aksimet
4)Submit Blog Comments and Getting a Blank Page
and various other terms and landed up to many blogs which had many bloggers complaining.
See even here i have not added my website url while commenting coz when i do so my comment won’t show up..it gives a blank page what you are talking about so i know the problem and i read your entire post without missing anything.
Akismet is hampering the blogging experience of many blog commenters who love to gel with others even though they are relatively new..this is really lame
I have even taken this whole issue to a next level..ya that is on Forums where it would gain a lot of exposure and maybe akismet would try to learn from it.
If this post goes through with the my website url in the website field then dear webmaster please mark it “unspam”
Thanks
August 12th, 2009 at 2:12 am
Thanks for this nice post. It has solved my few problems.