Stressing Over Blank Comments In WordPress

OMG! Better post this as a record for myself later and hopefully be helpful to you if you have a similar problem.

So… client sends SOS about WordPress comments not working. I figure this is probably something simple – when will I ever learn?

I run through the most common possibilities.

Miedo
Photo credit:
Arturo J. Paniagua

Check it for myself – not it’s not that I don’t trust clients words but sometimes when the code gods takes pity on you, they help you out, and the problem fixes itself. After all, why spend time fixing something when there is no problem right (and save clients some billable hours – I’m way too nice).

Problem not resolved. Time to get to work.

Comments not turned on? Could be, checked them comments are on globally and on each post.

Pop open the theme. Checked comments.php, nothing out of the ordinary.

Disabled plugins. Re-submit comment. No dice. Not plugin issue. Turned on default theme. Default theme works. Yay! At least I’m hitting some progress. It’s got to be the theme. But where?

Check for spaces and junk. Opened up theme files, wp-config.php, functions.php, wp-comments-post.php checked for additional spaces after ?>.

Aha! functions.php missing a closing ?> tag. Cleaned up all the other files.

Still nothing!

Search for solutions. Googled and searched WordPress.org. None of them were relevant or related. This cannot be!

By now, I’m getting a little pissed.

Made wp-post-comments.php tell me where the problem was. Put in error_log() so it can output errors. One error! Good. It was a plugin. So I disabled that plugin again – not very confident because I’d done it before and didn’t help. But what the heck, try it anyway.

No change and what’s worse, I now have no errors. Argh!

Asked for theme developer support area – the suggestion – reload the theme again. What?! I cannot do that. I’ve added or changed like 500 lines of code. Ugh.

Abandon suggestion. Instead, I load it the theme into my sandbox blog. It works! What the heck is going on?

By now I have a sinking sensation that I may have to back track every single thing I spent the last oh several months working on. I… just… can’t.

Now I’m angry.

Captain
Photo credit:
pusgums

Time to get creative but decided to give WordPress.org forums one more go. Miraculously, a new item popped up that didn’t before. The thread went on to discuss the possibilities that were new, along a path I hadn’t tried before.

That’s a good sign. I tried the suggestion. No dice.

But, it gave me a new clue. Using the knowledge and experience from developing several WordPress themes and sites, I tried my idea.

Woo Hoo! Success! Does a happy dance.

Solution:

For those of you who are technical and facing a similar issue here’s the deal. WordPress comments uses the post ID to track which comments are attached to which posts and also to redirect people back to the post after submission.

If a post ID is missing somewhere, comments either break or users are redirected to a blank page after submission because it doesn’t know where to redirect people to.

On this page in Codex (scroll to the very bottom), it tells you to make sure the code is there. It is.

On a hunch, I decided to check if the code is outputting properly. View source is an amazing tool. Sure enough the code is not writing the post ID to the form instead of

<input type="hidden" name="comment_post_ID" value="123" />

it was outputting

<input type="hidden" name="comment_post_ID" value="Array" />

Now, normally I would figure out why but time is not on my side, client getting antsy. The next best option is to try a different way to output the code. Instead of what Codex gives me which is

<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />

I used

<input type="hidden" name="comment_post_ID" value="<?php the_ID(); ?>" />

but that didn’t work out. I knew there was another way to output the post ID so tried this.

<input type="hidden" name="comment_post_ID" value="<?php echo $post->ID; ?>" />

That worked for me. Hope it works for you too. Good luck.

Do You Want A Hands-Free Business?

Then get this guide to help you systemize your business so you'll have more time working on your business.

!
!

Hey! I want to make sure you know what you're getting here. In addition to the guide, you will also receive our memo that includes special offers, announcements and of course actionable information.

Terms and Conditions checkbox is required.
Something went wrong. Please check your entries and try again.
Facebook Comments

19 Comments

  1. Andrea on August 1, 2008 at 7:10 pm

    This is also a really good post on how to troubleshoot the problem. 🙂

    I had an issue where upon submitting a comment, most of the blog comment would disappear.

    Turns out the sidebars had a negative margin & padding issue to force them the full length of the screen, and after leaving a comment, this forced the content “up” a few thousand pixels.



  2. Andrea on August 1, 2008 at 3:10 pm

    This is also a really good post on how to troubleshoot the problem. 🙂

    I had an issue where upon submitting a comment, most of the blog comment would disappear.

    Turns out the sidebars had a negative margin & padding issue to force them the full length of the screen, and after leaving a comment, this forced the content “up” a few thousand pixels.



  3. Lynette on August 2, 2008 at 12:55 am

    @Andrea: Hey there my friend. Oh… I bet that was frustrating for you. Agree with you indeed on how to troubleshoot. I think we all should have a checklist of most common stuff to run through.



  4. Lynette on August 1, 2008 at 8:55 pm

    @Andrea: Hey there my friend. Oh… I bet that was frustrating for you. Agree with you indeed on how to troubleshoot. I think we all should have a checklist of most common stuff to run through.



  5. Sandy Naidu on August 2, 2008 at 8:49 pm

    Thanks Lynette…In the old version of WordPress, if we under ‘Manage – Posts’ (in admin) we could see the post id. With 2.6 how do we know the post id of each post…Where is it stored…

    Thank You



  6. Sandy Naidu on August 2, 2008 at 4:49 pm

    Thanks Lynette…In the old version of WordPress, if we under ‘Manage – Posts’ (in admin) we could see the post id. With 2.6 how do we know the post id of each post…Where is it stored…

    Thank You



  7. Stephen on September 16, 2008 at 8:43 pm

    I’ve had the very same issue – very frustrating, thought I was going mad!



  8. Stephen on September 16, 2008 at 4:43 pm

    I’ve had the very same issue – very frustrating, thought I was going mad!



  9. Lynette on September 17, 2008 at 4:37 pm

    @Stephen oh we would make great pals. That was one of the most frustrating experiences with WP I ever had and 99% of the time WP works like magic for me.



  10. Lynette on September 17, 2008 at 12:37 pm

    @Stephen oh we would make great pals. That was one of the most frustrating experiences with WP I ever had and 99% of the time WP works like magic for me.



  11. eddie on September 25, 2008 at 9:04 am

    I have the quickest fix there is for the blank comments page thing that a lot of people seem to be noticing right here…



  12. eddie on September 25, 2008 at 5:04 am

    I have the quickest fix there is for the blank comments page thing that a lot of people seem to be noticing right here…



  13. Lynette on September 26, 2008 at 4:56 pm

    Hi Eddie, thanks for stopping by. I removed your link and put it in the profile. But it’s not quite helpful. It’s always easy to revert back to the default theme but I doubt anyone who has a serious blog wants to use the default theme. Maybe you left out some further instructions?



  14. Lynette on September 26, 2008 at 12:56 pm

    Hi Eddie, thanks for stopping by. I removed your link and put it in the profile. But it’s not quite helpful. It’s always easy to revert back to the default theme but I doubt anyone who has a serious blog wants to use the default theme. Maybe you left out some further instructions?



  15. eddie on September 27, 2008 at 9:02 am

    Once you switch to the default theme and it works you change back to what you were using previously.

    [e]



  16. eddie on September 27, 2008 at 5:02 am

    Once you switch to the default theme and it works you change back to what you were using previously.

    [e]



  17. Lynette on October 3, 2008 at 9:41 pm

    Thanks for clarifying Eddie. That makes sense.



  18. Lynette on October 3, 2008 at 5:41 pm

    Thanks for clarifying Eddie. That makes sense.